> Expat4D Home > Documentation > Command Reference

xml_SetErrorHandler ( errorHandlerMethod ) --> lastErrorHandler


  • --> errorHandlerMethod : string[31]
  • <-- lastErrorHandler : string[31]

Like 4D's ON ERROR CALL function, only this sets up an error handler for the Expat4D commands. Currently, the error handler routine is only called for errors which are only to do with Expat4D itself. Errors from expat are reported through the return values of xml_Parse and xml_ParseBlob.

This function returns the last errorHandler routine which was set using this function. This can be used to resetting the errorHandler to it's previous method after a particular operation.

Your error handler routine should be defined to allow two longint parameters. The first parameter contains the plug-in command number which caused the error. The second parameter contains the Expat4D error code which you can use the Expat4D error constants to check against.

The following code sample shows setting up the error handler.

`Method: xml_Parse (text)

C_TEXT ($1;$textToParse)

$textToParse:=$1

C_STRING(31;$lastErrorHandler)
$lastErrorHandler:=xml_SetErrorHandler ("expat4D_ErrorHandler")

C_LONGINT($parser;$error)
$parser:=xml_ParserCreate("")
xml_SetElementHandler($parser;"startTag";"endTag")
$error:=xml_Parse($parser;$textToParse;1)

`restore previous handler
$lastErrorHandler:=xml_SetErrorHandler ($lastErrorHandler)

The following code sample is a simple error handling routine.

   Method: expat4D_ErrorHandler (cmdNo; errorCode)

C_LONGINT($1;$commandNumber)
C_LONGINT($2;$errorCode)

$commandNumber:=$1
$errorCode:=$2

ALERT("Expat4D ErrorCode "+String($errorCode)+" occurred in Command Number "+String($commandNumber))

  Expat4D Logo

Developer Documentation

Creating Parsers, Destroying Parsers, Parsing Text

Configuring Handler Methods

Position and Error Reporting Functions

Miscellaneous Functions

Output Buffer Functions

Error Codes


> Expat4D Home > Documentation > Command Reference

Last Modified: 27th April 2001 at 9:00 PM