gdiasdasilva /
benfica-live
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Exceptions; |
||
| 4 | |||
| 5 | use Exception; |
||
| 6 | use App\Mail\ExceptionOccurred; |
||
| 7 | use Illuminate\Support\Facades\Mail; |
||
| 8 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
||
| 9 | |||
| 10 | class Handler extends ExceptionHandler |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * A list of the exception types that are not reported. |
||
| 14 | * |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | protected $dontReport = [ |
||
| 18 | // |
||
| 19 | ]; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * A list of the inputs that are never flashed for validation exceptions. |
||
| 23 | * |
||
| 24 | * @var array |
||
| 25 | */ |
||
| 26 | protected $dontFlash = [ |
||
| 27 | 'password', |
||
| 28 | 'password_confirmation', |
||
| 29 | ]; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Report or log an exception. |
||
| 33 | * |
||
| 34 | * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
||
| 35 | * |
||
| 36 | * @param \Exception $exception |
||
| 37 | * @return void |
||
| 38 | */ |
||
| 39 | public function report(Exception $exception) |
||
| 40 | { |
||
| 41 | if (app()->environment() === 'production' && $this->shouldReport($exception)) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 42 | $this->sendEmail($exception); |
||
| 43 | } |
||
| 44 | |||
| 45 | parent::report($exception); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Render an exception into an HTTP response. |
||
| 50 | * |
||
| 51 | * @param \Illuminate\Http\Request $request |
||
| 52 | * @param \Exception $exception |
||
| 53 | * @return \Illuminate\Http\Response |
||
| 54 | */ |
||
| 55 | public function render($request, Exception $exception) |
||
| 56 | { |
||
| 57 | return parent::render($request, $exception); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Send an email to the administrator with the exception. |
||
| 62 | * |
||
| 63 | * @param \Exception $exception |
||
| 64 | * @return void |
||
| 65 | */ |
||
| 66 | public function sendEmail(Exception $exception) |
||
| 67 | { |
||
| 68 | Mail::to(config('benficalive.administrator_email')) |
||
| 69 | ->send(new ExceptionOccurred($exception)); |
||
| 70 | } |
||
| 71 | } |
||
| 72 |