Laravel 5.5 Adds Support for Custom Exception Reporting

Laravel 5.5 Adds Support for Custom Exception Reporting

In Laravel 5.5 it will be possible to define a report method on any custom exception. Laravel will look for the existence of the report method on any exception that it catches in the Illuminate\Foundation\Exceptions\Handler class.

if (method_exists($e, 'report')) {
    return $e->report();

This is a convenient place to send a notification email to the developer, report to your application monitoring software, or carry out any other action you may require in the event the exception is thrown.

In previous versions of Laravel, it was possible to achieve the same result by editing the report method of the App\Exceptions\Handler class. Here you can listen for an instance of a particular exception and carry out your action accordingly.

public function report(Exception $exception)
    if ($exception instanceof MyException) {
        // do something here such as send an email to developer or notify monitoring app

    return parent::report($exception);

As you can imagine, as your application grows, this can become a little messy and difficult to maintain.

This small change coming to Laravel 5.5 will make a huge difference in ensuring this is no longer an issue.

Filed in: Laravel 5.5 / Exceptions


Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Experienced PHP Developer
Wilmington, NC
Queensboro Shirt Company
Senior Laravel developer
Netherlands, Rotterdam
Senior Laravel Engineer
Remote okay (must already live in USA)
Hawthorne Effect
Senior Software Engineer (Remote - Contract)
Koodi Systems
PHP Developer
Pittsburgh / Remote
Sequoia Waste Solutions
Software Developer
Simac IDS
Application Developer Level II (CakePHP / MySql / Vue.js)
Lancaster, PA
Harbor Compliance