cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1372
Views
3
Helpful
9
Replies

How to capture AudiumExceptions

Chintan Gajjar
Level 8
Level 8

Team,

i am looking for capturing audium exception in my custom decision element.

i dont want to use error element. is there any way i could just handle in the same custom code itself?

i wrote this element to handle db exception, but now i am facing challenge in handling audium exceptions.

Chintan

9 Replies 9

janinegraves
Spotlight
Spotlight

Which version of Studio - are you working with 10.5? Or earlier?

9.0(1)

In your code, just catch Exception (instead of RuntimeException) -

that'll catch the audium exception.

unfortunately that's not working. even if i have catch block to cover my code. the element errors out with audium exception(and eventually error announcement).

i want capture in and allow it to go through error exit state of element.

i tried catching audium exception as well but that did not help.

this is how i have placed my catching.

catch (AudiumException e)

  {

  exitState = "ELEMENT ERROR";

  arg1.addToLog("ERROR:", e.getLocalizedMessage().toString());

  }

catch (SQLException e)

  {

  exitState = "ELEMENT ERROR";

  arg1.addToLog("ERROR:", e.getLocalizedMessage().toString());

  }

catch (Exception e)

  {

  exitState = "ELEMENT ERROR";

  arg1.addToLog("ERROR:", e.getLocalizedMessage().toString());

  }

Are you extending the Cisco Database element?

If so, then your element must remain an Action element (not a Decision

element). But you can set Element or Session data that you then check in

a regular decision element to see if an error occurred.

I've done this in the past, and it always worked fine.

public class JaninesDatabaseElement extends DatabaseAction implements

ElementInterface

{

public String getElementName() { return "JaninesDatabase"; }

public String getDisplayFolderName() { return "Janines

Elements"; }

public String getDescription() { return "Execute Cisco Database

Element, catch Exceptions by setting Element data named 'status' to

'success' or 'failure'"; }

*public void doAction(String name, ActionElementData actionData)

throws AudiumException**

    • { **

    • String status="success";**

    • try {**

    • super.doAction(name,actionData);**

    • } catch (AudiumException e) {**

    • status = "failure";**

    • }**

    • actionData.setElementData("status",status)**

    • }*

No i have written new Decision element to perform JDBC.

i never knew that we could extend a DB element, that's really great stuff.

i would see if i could find some way to do it by tweaking java.

chintan

If you've written your own element, then you don't need to extend

Cisco's element. And you shouldn't need to catch AudiumException -

unless you write something incorrectly.

I wrote a simple DB element (as an Action, but you can easily change it

to a Decision element).

You should be able to do something like this:

public void doAction(String name, ActionElementData data) throws

ElementException

{

String user="user";

String password="pwd";

String driverClass="com.mysql.jdbc.Driver";

String jdbcString="jdbc:mysql://localhost:3306/rx";

Connection con = null;

Statement st = null;

ResultSet rs = null;

// get a connection here. this creates an empty jdbc object

try {

Class.forName(driverClass).newInstance();

con = DriverManager.getConnection(jdbcString,user,password);

// this reads and displays all the records in the rxtable

st = con.createStatement();

rs = st.executeQuery("SELECT * FROM RXTABLE");

while (rs.next()){

//get values by col index or by name

//do something here

}

} catch (Exception e) {

System.out.println("exception:"+e.getMessage());

} finally {

try {

if(rs != null) rs.close();

if(st != null) st.close();

if(con != null) con.close();

} catch (SQLException e) { }

}

}

To extend Cisco elements, you have to include elements.jar in the

classpath, It's located in CVP/VxmlServer/common/lib.

Is this not catching it ?

catch (Exception e) {

//Log here

element.addToLog("exception:"+e.getMessage());

}

Hemal