Whenever errors occur, JCo throws an exception. All sxceptions that occur in the JCo are passed on to the registered Exception and Error Listener.
Note
The application must process the exceptions separately in the method handleRequest()(that is, the exceptions that it generates itself). Exceptions from the application coding are not passed on to the Listener.
JCO.ServerExceptionListener and JCO.ServerStateChangedListener:
JCO.ServerExceptionListener and JCO.ServerStateChangedListener:
Syntax
public class MyExceptionAndErrorListener
implements JCO.ServerExceptionListener, JCO.ServerErrorListener {
public void serverExceptionOccurred(JCO.Server server, Exception ex)
{
System.out.println("Exception in server " + server.getProgID() + ":\n" + ex);
ex.printStackTrace();
}
public void serverErrorOccurred(JCO.Server server, Error er)
{
System.out.println("Error in server " + server.getProgID() + ":\n" + er);
er.printStackTrace();
}
}
Register the Listener class with JCO.addServerErrorListener and
JCO.addServerExceptionListener:
Syntax
public class SecondExample extends FirstExample {
public static void main(String[] args) {
MyExceptionAndErrorListener l = new MyExceptionAndErrorListener();
JCO.addServerErrorListener(l);
JCO.addServerExceptionListener(l);
FirstExample.startServers() ;
}
}