Oracle9iAS Portal Developer Kit
A Primer on Error Handling

Oracle9iAS Portal provides consistent ways to trap erroneous input and provide meaningful error messages.  The Portal has methods for managing the internal error stack.  This stack keeps track of raised exceptions and information about those errors.  Oracle9iAS Portal also has a set of APIs for presenting errors in a standardized way.

Error handling services are available through the  wwerr_api_error  and  wwerr_api_error_ui packages.

Key Features

Error handling services in the Oracle9iAS Portal framework have the following key features.

Error Messages

Error handling services provide a way to define meaningful error messages.  To define your own error messages, you need to define its name space.  That name space consists of:

The name space uniquely identifies your error message. If it does not do so, a 'wwc-0000' error message will be generated.

The default domains include the Portal (WWC), Application (WWV) and Content Areas (WWS).  Each domain is further classified into sub-domains which define the object types.  The Oracle9iAS Portal domain includes Portlet, Page, Document object types; the Application domain includes Form, Menu, Report, Chart etc.; and the Content Area domain includes Folder, Item, Category, Perspective etc.  If you need to define a different type of error that does not fall within these domains and sub-domains classification, define your own domain and sub-domains for your errors.

Error Stack

Oracle9iAS Portal uses an error stack to keep track of the error messages.  The error messages are pushed on to an Error Stack whenever errors occur. Whenever procedures or function calls are nested, the error stack keeps track of all the error messages.  You can choose to retrieve only the top error ( or most recent error) by using the wwerr_api_error.get_top method.  Alternatively you can get all the error messages on the stack by using wwerr_api_error.get_errors method.  The stack can also be checked for presence of any errors by calling the wwerr_api_error.is_empty method.

Message Parameters

The NLS strings that you create for your errors can take substitution parameters for your messages. For example with NLS string: 

(domain='yahoo', subdomain='provider', name='generalerror', string='Error: %1') 

an error can be added as :
wwerr_api_error.add(p_domain=>'yahoo',  p_sub_domain=>'provider',  p_name=>'generalerror',  p_context=>'yahoo.show',  p1
=> sqlerrm);

The p1, p2, p3.. parameters can be used to pass substitution parameters to the error messages. 

Error Display

The wwerr_api_error_ui package provides a means to generate a standard User Interface for displaying the errors in Oracle9iAS Portal. The error messages can be displayed in two different ways:

Additionally you can choose the output format of the display from:

How to Use Error Handling

The general model for working with the error handling can be described as follows:

  1. On detecting erroneous conditions, add the error message, with an appropriate domain and sub-domain combination, using the wwerr_api_error.add method.  This adds the error message to the stack.
  2. At the end of a routine, or as per your requirement, expose the error messages using the wwerr_api_error_ui calls.  To display full screen messages, use the methods show_html, show_xml or show_text depending on the output type you desire.  To display inline messages, use the methods show_inline_html, show_inline_xml or show_inline_text depending on the output type you desire.

Note: Remember to seed the NLS strings for your error messages.  The document on Implementing NLS Service describes how string definitions are loaded into the database.

The standard UI for error messages also provides a navigation link to go back to the previous page.  It also includes a 'Help' icon to link to the specified Help URL.

Tips for using Error Handling

While handling errors with the provided API, keep in mind the following:

Error Handling usage hints

For further details regarding implementation, refer to Implementing Error Handling.


Revision History