05-19-2015 07:10 AM
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
05-19-2015 07:13 AM
Which version of Studio - are you working with 10.5? Or earlier?
05-19-2015 07:15 AM
9.0(1)
05-19-2015 07:17 AM
In your code, just catch Exception (instead of RuntimeException) -
that'll catch the audium exception.
05-19-2015 07:26 AM
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());
}
05-19-2015 07:51 AM
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)**
}*
05-19-2015 07:58 AM
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
05-19-2015 08:19 AM
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) { }
}
}
05-19-2015 08:20 AM
To extend Cisco elements, you have to include elements.jar in the
classpath, It's located in CVP/VxmlServer/common/lib.
05-19-2015 11:24 AM
Is this not catching it ?
catch (Exception e) {
//Log here
element.addToLog("exception:"+e.getMessage());
}
Hemal
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide