Exceptions

The Blueworx Voice Response Java API uses a fairly standard exception model. Some exceptions are expected, like WVRRequestCancelledException or WVRHungUpException, but most are thrown when the application encounters an error condition. The exceptions are arranged into a hierarchy. The hierarchy groups related exceptions together and allows you to catch a whole group of exceptions in one go by catching the exception that is the base class for the group. For instance all exceptions relating to the Call class are either direct or indirect sub classes of WVRCallException. The base classes are as follows:

Figure 1. Overview of Blueworx Voice Response Java API exceptions
This picture shows the hierarchy of WVR exception families.

These base class exceptions are never actually thrown themselves, they are only used for catching groups of exceptions. You can also catch individual exceptions. The most likely exception you would want to catch in this way would probably be WVRHungUpException. For example:

  try {
    // Execute some code
    .
    .
    .
  }
  catch (WVRHungUpException ex) {
    // Catches an individual exception - in this case the caller has hung up
  }
  catch (WVRCallException ex) {
    // Catches all exceptions that inherit from WVRCallException that have
    // not already been caught (in other words, not WVRHungUpException) -
    // the application has encountered an error condition
  }
  catch (WVRException ex) {
    // Catches all WVR exceptions not already caught - the application has
    // encountered a further error
  }

For more information and details of individual exceptions, see the JavaDoc supplied with this documentation.

Multi-threading

We advise against writing multi-threaded apps using the Blueworx Voice Response Java API. However, if your application does do multi-threading and a thread tries to invoke a telephony method, such as Call.transfer(), on a Call object at the same time as another thread, then a java.lang.IllegalStateException will be thrown.

If your application is multi-threaded, try to avoid inter-thread interaction by creating a different Call object for each thread.