I followed a tutorial and looked Laravel's docs for registering a custom error handler.
I register the class, and throw MyCustomException, but for some reason, it ignores everything in it and just runs the regular Exception class. The code below prints out exception 'MyCustomException' with message 'This is NOT the message I want to see' instead of "This is the custom exception message"
Currently all the code below is just on a test page, but I've tried registering the class (and putting the MyCustomException declaration) into global.php before Exception and I've tried after Exception as well. Nothing changes.
I've tried sleep(10) inside of MyCustomException too, and that doesn't get run; MyCustomException just doesn't get run.
What am I doing wrong?
Edit: in fact, copying and pasting the code from the tutorial results in the same thing as my custom code; the custom exception handler doesn't get run.
class MyCustomException extends Exception {}
App::error(function(MyCustomException $exception) {
return "This is the custom exception message.";
});
//Now throw the error and see what comes out
try {
throw new MyCustomException('This is NOT the message I want to see');
} catch (MyCustomException $e) {
die($e);
}