77
loading...
This website collects cookies to deliver better user experience
app/Exceptions/Handler.php
handler file. This is where Laravel gives you the option to send exceptions to Sentry, Bugsnag, or any other bug reporters you want to set up. This is also where we will be logging to our Slack channel.public function report(Exception $exception)
{
parent::report($exception);
}
parent::report($exception)
as we are going to be doing this ourselves.public function report(Exception $exception)
{
// You can specify which exceptions not to report here
if ($this->shouldntReport($exception)) {
return;
}
// We are getting the directory so we can filter out any vendor code,
// along with the directory, so it looks better for the developer.
$dir = substr(__DIR__,0,-14);
$backtrace = $exception->getTraceAsString();
$backtrace = str_replace([$dir],"", $backtrace);
$backtrace = preg_replace('^(.*vendor.*)\n^','',$backtrace);
// And finally, we log the exception!
Log::channel('slack')->error('@here'.PHP_EOL.' . PHP_EOL . '**Error:** '.$exception->getMessage() . PHP_EOL. '**Line:** ' . $exception->getLine() . PHP_EOL. '**File:** '. $exception->getFile() . PHP_EOL . '**Trace:**'.PHP_EOL. $backtrace);
}