I only want to handle certain query exception codes. The rest I want to let go; so that I get the regular debug or Oops, something went wrong screen, depending on my environment.
I currently have the following code in my routes.php file, it seems to work. But is it the correct way of doing it?
// Query Exceptions
App::error(function(QueryException $exception)
{
$allowedCodes = array(
'23000', // Integrity constraint violation
);
if (in_array($exception->getCode(), $allowedCodes))
{
return Response::view('errors.show', array('code' => 'query_error_' . $exception->getCode()));
}
else
{
App::error(function(QueryException $exception){});
}
});
Update, here was the solution I ended up based on Jarek Tkaczyk's answer:
App::error(function(QueryException $exception)
{
$allowedCodes = array(
'23000', // Integrity constraint violation
);
if (in_array($exception->getCode(), $allowedCodes) && !App::environment('local'))
{
Log::warning('QueryException', array('context' => $exception->getMessage()));
return Response::view('errors.show', array('code' => 'query_error_' . $exception->getCode()));
}
});
elsedoes nothing.elsedoes this: Register empty error handler, while you are already in the error handler. This piece doesn'tre-throwthe error, as you asked in the q title, that's all.