expectsJson() ? response()->json(['message' => $exception->getMessage()], 401) : redirect()->guest(url('/login')); } public function report(Throwable $exception) { if ($this->shouldReport($exception) ) { if (app()->bound('sentry') && $this->sentryShouldReport($exception)) { app('sentry')->captureException($exception); Log::debug('Un-handled Exception: '.$exception->getMessage(), [ 'exception' => $exception, 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'trace' => $exception->getTrace(), ]); } } parent::report($exception); } public function render($request, Throwable $e) { if ($this->shouldReport($e) && !in_array(\App::environment(),['testing']) && config('logging.channels.slack.enabled')) { Log::channel('slack')->error($e); } return parent::render($request, $e); } private function sentryShouldReport(Throwable $e) { foreach ($this->sentryDontReport as $exceptionType) { if ($e instanceof $exceptionType) { return false; } } return true; } }