Portlet Factory, Version 6.1.2


 

Catching a timeout exception

Perform the following steps to catch a timeout exception.

  1. Create a page to be displayed if the service call or SQL transaction times out.

  2. On that page, include a named <span /> tag to be used for a Text builder call that displays the message from the timeout exception.

    This example uses FailurePage for this page name.

  3. Add a variable to your model.

    This example uses ErrorMessage for the variable name.

  4. Add a Text builder to your model.

  5. Locate the Text builder on the page and tag that you created.

  6. Set its Text input to the value of the ErrorMessage variable.

    For example, ${Variables/ErrorMessage}.

  7. Add a Method named handleTimeout, with the following Body value:
    {
     HttpServletRequest request = webAppAccess.getHttpServletRequest();
     Throwable ex = (Throwable)request.getAttribute("bowstreet.errorhandler.Exception");
     String actionName = (String)request.getAttribute("bowstreet.errorhandler.ActionName");
     String errorMessage = ex.toString() + " occurred in: " + actionName;
     webAppAccess.getVariables().setString("ErrorMessage", errorMessage);
     webAppAccess.processPage("FailurePage");
    }

  8. Add an Error Handler builder call to your model, with the following input values:

    Try Action

    Set to the invoke method for the service call or SQL statement. For example, ServiceCallTest.invoke.

    Catch Action

    Set to the model action that handles the error. In this case, handleTimeout.

Parent topic: Example: catching a timeout exception


Library | Support |