try. Intercepting and handling errors

^try{the code whose errors get…}{…into this handler as $exception}
^try{the code whose errors get…}{…into this handler as $exception}{the code which will be executed anyway}

If an error occurred during processing the
code, a variable $exception will be created and control over processing will be handed over to handler.
If third parameter was specified, that code will be executed anyway regardless of unhandled exception.

$exception is such a hash:

string, error type.
There is a number of system error types; a type can also be defined in operator throw.
string, error source (wrong filename, method's name, …)
file containing source, line and column numbers in it
error comment, in English
true or false, flag "if error has been handled"
you will need to set the flag in the handler if you have handled the received error

Handler must report Parser if the error has been handled. For this purpose, it must set the flag but only for the needed error types:

handler has not set the flag, the error is considered unhandled and will be handed over to another handler, if it exists.

If the error remains unhandled, method
unhandled_exception is called. This method will receive information on the error as well as the stack of calls that caused it. The method's work will result in a custom message to be output to a visitor. The error will also be recorded in server's error log.


eq xml){
      Invalid XML,

Copyright © 1997–2017 Art. Lebedev Studio | Last updated: 24.06.2012