shouldReport($exception)) { if (config('app.env') == 'demo') { $this->sendEmail($exception); // sends an email in demo server } } parent::report($exception); } /** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Throwable $exception * @return \Illuminate\Http\Response */ public function render($request, Throwable $exception) { return parent::render($request, $exception); } /** * Sends the exception email * * @param $exception */ public function sendEmail(Exception $exception) { try { $e = FlattenException::create($exception); $handler = new SymfonyExceptionHandler(); $html = $handler->getHtml($e); $email = env('MAIL_USERNAME'); if (! empty($email)) { Mail::to($email)->send(new ExceptionOccured($html)); } } catch (Exception $ex) { dd($ex); } } }