I have an application based on Zend Framwork. In one Model I am calling a method from another Model. When I call this method I use try-cath block for handling of strange situations.
Model1.
try {
$result = Module_Model2_Name->method();
} catch (Exception $e) {
// Do Something
}
Catch should be work if we find a throw in try block. But I don’t know about behaviour of my application. If it is a some application error in Model2 method it should be throw an Exception.
In method of Model2 I do the next thing, but it doesn’t work:
set_error_handler(create_function('$m = "Error"','throw new Exception($m);'), E_ALL);
How can I throw an Exception on every PHP application error?
Thank you very much. Sorry for my English.
It looks good to me (tested it).
Please note that:
Taken from the PHP manual.