Hi,
What i did was writing a function that simply throws an exception and
passing that function to set_error_handler, something like this:
error_reporting(E_ALL);
function exceptionThrower($type, $errMsg, $errFile, $errLine) {
throw new Exception($errMsg);
}
set_error_handler('exceptionThrower');
try {
echo $a['b'];
} catch ( Exception $e ) {
echo "Sorry: ", $e->getMessage();
}
Only trouble with the errorcontroller is that it only catches the
exceptions inside the dispatch loop, so I disabled that and put a try /
catch around the entire bootstrap/dispatch and handle the exceptions
myself, so I can easily implement 401 / 403 / 404 / 500 response codes
based on the type of exception, no matter if it is thrown within the
dispatch loop.
drm / Gerard
Саша Стаменковић wrote:
I'm trying to do this with set_error_handler(), my will is to trigger
Error controller and catch this as application error, since I want to
log all errors in one place - Error controller.
I tried with setting error handler in bootstrap to function in
index.php and that function calls error controller statically, but no
success. There must be some easy way to do this.
Anyone know?
Regards,
Saša Stamenković