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:
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
While defining your own error messages, use your own error domain for these messages. Never use the domain WWC, WWV or WWS for your error messages. You will need to write a small loader script to load these into the NLS tables.
Avoid unnecessary error messages. If you do not want to do anything in a function just return null, not an error. For example, say you are coding a copy_portlet procedure in a portlet since the provider calls it for its other portlets. If you do not wish the copy_portlet procedure for this particular portlet to do anything, then just return null. If you return errors, this will unnecessarily disrupt the portlet functionality.
Maximum of 10 error messages on the stack. Keep in mind that you can add up to 10 error messages on the stack at a time. Beyond that number, additional messages get ignored when an wwerr_api_error.add call is made.
Output format for HTML works. In the future the XML and ASCII text format for output will also be implemented.
Use the API for a programmatic way of finding the problem. You can use a non-ui format for determining the problems. For example when programmatically registering a provider the exception block can use get_text_stack to get the error messages and then can print them out. This helps when debugging calls to Public APIs since all of them add errors to the stack when exceptions are raised.
For further details regarding implementation, refer to Implementing Error Handling.
Revision History
November 14, 2000.