Skip to content

Rethrowing exceptions from error handler #1807

Closed
@alexwhitman

Description

@alexwhitman

I've got a couple of error handlers:

App::error(function(\Illuminate\Database\Eloquent\ModelNotFoundException $exception)
{
    // Both end up with an "Error in exception handler" error.
    //App::abort(404);
    //throw new Symfony\Component\HttpKernel\Exception\HttpException(404, null, $exception);
});

App::error(function(\Symfony\Component\HttpKernel\Exception\HttpException $exception)
{
    // I want to end up in here where I have generic http error handling code
});

Using MyModel::findOrFail($id) can throw the ModelNotFoundException which I'm catching but using App::abort or throwing a new exception from within the handler errors with an "Error in exception handler" error (from https://github.com/laravel/framework/blob/master/src/Illuminate/Exception/Handler.php#L318).

Is it not possible to re-throw an error in this way?

I can work around it by overriding findOrFail() in a base Model but I was wondering if the above could or should work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions