Ad

Laravel 4.2 Custom Error Handler Not Working

- 1 answer

I am trying to handle InvalidArgumentException in a custom way. In app/start/global.php I have the following code block after the built in App::error(Exception $exception... block:

App::error(function(InvalidArgumentException $exception, $code){

//    die('last');

    $exceptionData['exception'] = $exception;
    $exceptionData['code'] = $code;

    ExceptionNotificationHandlerController::notify($exceptionData);

});

die()ing, breakpoints, etc all suggest to me that it never goes into that block of code when I throw an InvalidArgumentException. Help?

Ad

Answer

Okay, just for anyone having this problem it seems that having 'debug' => true set in app/config/app.php prevents you from using your custom exception handlers properly. Once I set that to false all my problems went away. Annoyingly, you're supposed have this set to true while working in local environment. Even more annoyingly, it appears that once you set debug to false you can no longer get the exception message with $exception->getMessage().

Ad
source: stackoverflow.com
Ad