Online documentation - Websydian v6.0

Users Guide | Patterns Reference | WebsydianExpress | Search

 

Websydian DOM - Other Uses


Error Handling

All Websydian functions of the TransacXML patterns (WSYDOM, WSYXML and WSYSOAP) sets the *Returned status to ERR in case of errors. It is very important that the developer makes sure to handle any error states returned by the Websydian functions.

In order to investigate the cause of the problem an error stack has been implemented which holds information about the errors. For further information on using the error stack see below.

Examples of error handling can be seen in the function WSYXML/ImportXMLDocument.

Using the Error Stack

Websydian DOM implements an error stack making it easier to trace errors in the XML parser, and other TransacXML functions. Whenever an error occurs in the parser or any TransacXML functions, an element holding information about the error is pushed onto the error stack.

The error stack is also used by the WSYXML and WSYSOAP patterns enabling further information about errors encountered during calls to functions of these patterns.

For an example of using the error stack open the action diagram of the function WSYXML/ImportXMLDocument and look into the subroutine Check error.

Popping an Error Stack Element

After a call to a function in Websydian DOM *Returned status should be checked. If the *Returned status is state *Error the call to the function failed and the detailed error message(s) can be fetched by popping the error stack.

This is done by a call to the function DomServices.ErrorPop.

The ErrorPop function has three output parameters:

ExceptionCode
ErrorDescription
ExceptionCode2

The ExceptionCode and ErrorDescription parameters contain values from the error stack element just popped. The ExceptionCode2 contains an exception code if any error occurred as a result of the ErrorPop call, e.g. if the error stack is empty.

An example of looping through all available error messages in the error stack:

Call DomServices.ErrorPop

While DomServices.ErrorPop/Output<ExceptionCode2> IS <State: WSYDOM/ExceptionCode2.NO_EXCEPTION>

  Cast Environment<*Message text>, DomServices.ErrorPop/Output<ErrorDescription>

  // Add code handling the error message here
  Call WSYDOM/DomServices.ErrorPop

Clearing the Error Stack

All elements can be removed from the error stack by making a call to the ErrorClear function:

Call DomServices.ErrorClear