Laravel package whoops exception

2k Views Asked by At

In my Laravel package I have this code:

try {
    $var_msg = "Exception example";
    throw new InvalidNameException($var_msg);
}
catch (InvalidNameException $e) {
    abort(403, $e->getMessage());
    //report($e);Exception Log
}

The error is displayed as html error page. But, I'd like to report the error as an whoops error.

Error Image

1

There are 1 best solutions below

4
Prashant Deshmukh..... On BEST ANSWER

Take this code as reference.

    $whoops = new \Whoops\Run();
    $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());

    // Set Whoops as the default error and exception handler used by PHP:
    $whoops->register();

    throw new \RuntimeException("Oopsie!");