kumar
kumar

Reputation: 1826

Error handling in Laravel

Can anyone explain what all errors can App::error of Laravel handles..?

For eg :

  1. [404] unable to access the url
  2. [500] internal server error

If I have a db connection error or any missing parameter error it doesn't come under this class. How can I handle those major errors..?

Please help in listing all the possible cases..

Upvotes: 1

Views: 227

Answers (1)

Andy Fleming
Andy Fleming

Reputation: 7875

The error handling isn't specifically tied to HTTP status codes.

App::error handles any uncaught exceptions. A not found error is just a NotFoundHttpException.

http://laravel.com/docs/4.2/errors#handling-errors


A 404 exception can be easily caught with this shortcut method:

App::missing(function($exception)
{
    // Example response
    return Response::view('errors.missing', array(), 404);
});

http://laravel.com/docs/4.2/errors#handling-404-errors

If you don't use the App::missing syntax, a not-found type of exception should bubble up to the App::error handler.

Upvotes: 1

Related Questions