Error Handler Script¶
Channel Properties → Error Handler tab. Check Enable Error Handler Script to enable the script and enter the body in the editor below.
When a message errors during channel processing, either by throwing an unhandled JavaScript exception, calling message.error(...), qie.simulateSendError(...), qie.throwAckError(...), or a plain throw, QIE runs the Error Handler Script before placing the message in the error queue. The script can:
- Discard the message. Calling
message.discard()routes the message to the completed queue instead of the error queue. Use this when the error is recoverable in some way that does not require operator review (duplicate-message detection, expected partial failures). - Inspect or modify state. The script can read the message, the source, the exception details, and the channel/zone identifiers, and can update the channel cache, message cache, or shared cache.
- Let the message proceed to the error queue. Default behavior. If the script does not call
message.discard(), the original exception is re-thrown after the script finishes and the message lands in the error queue as it would have without the handler.
The following bindings are available in the script:
| Binding | What it holds |
|---|---|
source |
Original unmodified source message |
message |
Current (potentially modified) message |
messagePath |
Node path where the error occurred (if applicable) |
exceptionToHandle |
The Java/JavaScript exception object |
exceptionMessage |
Exception message text |
exceptionClass |
Exception class name |
exceptionFunction |
Function name where the exception was thrown |
exceptionLine |
Line number where the exception was thrown |
channelCache, messageCache, sharedCache |
Standard cache objects |
channelId, channelName, zoneId, zoneName |
Channel and zone identifiers |
qie, StringUtils, NetFile, hapi |
Standard QIE script libraries |