2004
Colin Adams and others
Colin
Adams
colin@colina.demon.co.uk Tuesday, October 19th, 2004

# The Error Listener

The Error Listener receives notification of all warnings and errors (whether recoverable or not) generated when compiling the stylesheet, or produced by the `XM_XSLT_TRANSFORMER`.

XSLT defines some errors as recoverable (and specifies optional recovery options), and others as non-recoverable. Conditions not defined by XSLT are raised by the library as warnings.

## Features

The following features may be of interest to the Eiffel programmer:

recovery_policy: INTEGER / set_recovery_policy (a_recovery_policy: like recovery_policy)

  The recovery policy is an instruction to the error routine as to how to handle recoverable errors. If it evaluates to Recover_silently, then error is supposed to set recovered to True, and not issue any message (although it may choose to log the error).

  If it evaluates to Recover_with_warnings, then it should additionally inform the user of the recovered condition, provided recoverable_error_threshold has not been exceeded (although it is not obliged to honour this threshold).

  If, however, it evaluates to Do_not_recover, then it should inform the user of the error condition, and set recovered to False.

warning_threshold: INTEGER / set_warning_threshold (a_warning_threshold: like warning_threshold)

  This threshold is available to request the warning routine not to issue an informatory message once this number of warning messages have been issued.

recoverable_error_threshold: INTEGER / set_recoverable_error_threshold (a_recoverable_error_threshold: like recoverable_error_threshold)

  This threshold is available to request the error routine not to issue an informatory message once this number of recoverable errors have been seen.

warning (a_message: STRING; a_locator: XM_XPATH_LOCATOR)

  This routine is called by the library to warn of problematic conditions which are not defined as errors by XSLT. It should inform the user (in some unspecified way) about the condition, provided that warning_threshold has not been exceeded (but there is no obligation to maintain a count of warning messages, so a pure error listener may well ignore this threshold).

error (a_message: STRING; a_locator: XM_XPATH_LOCATOR)

  This routine is called by the library to inform the user (in some unspecified way) about a recoverable error, provided that recoverable_error_threshold has not been exceeded (but there is no obligation to maintain a count of error messages, so a pure error listener may well ignore this threshold) and perhaps recover from the error (both actions depend upon the current setting of recovery_policy).

  This routine must set recovered to True if it recovers from an error, so that the transformer can take the defined recovery action. (This probably means that a pure error listener will only implement a policy ofDo_not_recover.)

fatal_error (a_message: STRING; a_locator: XM_XPATH_LOCATOR)

  This routine is called by the library to inform the user (in some unspecified way) about a non-recoverable error.

treat_warnings_as_recoverable_errors

  This routine may be called by the programmer on an error listener, to request the warning routine to behave identically to the error routine.

## The default error listener: `XM_XSLT_DEFAULT_ERROR_LISTENER`

This is the only concrete error listener provided by the library. It maintains error counts. The recovery policy is passed as an argument to the creation routine, as also is a `UT_ERROR_HANDLER` to receive the warning and error messages.