webshelf /
framework
We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Exceptions; |
||
| 4 | |||
| 5 | use Exception; |
||
| 6 | use PDOException; |
||
| 7 | use App\Http\Controllers\ErrorController; |
||
| 8 | use Illuminate\Auth\AuthenticationException; |
||
| 9 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
||
| 10 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
||
| 11 | |||
| 12 | class Handler extends ExceptionHandler |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * A list of the exception types that are not reported. |
||
| 16 | * |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected $dontReport = [ |
||
| 20 | // |
||
| 21 | ]; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * A list of the inputs that are never flashed for validation exceptions. |
||
| 25 | * |
||
| 26 | * @var array |
||
| 27 | */ |
||
| 28 | protected $dontFlash = [ |
||
| 29 | 'password', |
||
| 30 | 'password_confirmation', |
||
| 31 | ]; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Report or log an exception. |
||
| 35 | * |
||
| 36 | * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
||
| 37 | * |
||
| 38 | * @param \Exception $exception |
||
| 39 | * @return void |
||
| 40 | */ |
||
| 41 | public function report(Exception $exception) |
||
| 42 | { |
||
| 43 | parent::report($exception); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Render an exception into an HTTP response. |
||
| 48 | * |
||
| 49 | * @param \Illuminate\Http\Request $request |
||
| 50 | * @param \Exception $exception |
||
| 51 | * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response |
||
| 52 | */ |
||
| 53 | public function render($request, Exception $exception) |
||
| 54 | { |
||
| 55 | if (app()->isLocal() && ! $exception instanceof NotFoundHttpException) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 56 | return parent::render($request, $exception); |
||
| 57 | } |
||
| 58 | |||
| 59 | if ($this->hasDisabledSite()) { |
||
| 60 | return ErrorController::maintenance(); |
||
| 61 | } |
||
| 62 | |||
| 63 | if ($exception instanceof NotFoundHttpException) { |
||
| 64 | return ErrorController::unknown(); |
||
| 65 | } |
||
| 66 | |||
| 67 | if ($exception instanceof PDOException) { |
||
| 68 | return ErrorController::database(); |
||
| 69 | } |
||
| 70 | |||
| 71 | if ($exception instanceof AuthenticationException) { |
||
| 72 | return parent::render($request, $exception); |
||
| 73 | } |
||
| 74 | |||
| 75 | return parent::render($request, $exception); |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * See if the site has been disabled by the tenant for maintenance errors. |
||
| 80 | * |
||
| 81 | * @return bool |
||
| 82 | */ |
||
| 83 | private function hasDisabledSite() |
||
| 84 | { |
||
| 85 | return settings()->getValue('maintenance_mode'); |
||
| 86 | } |
||
| 87 | } |
||
| 88 |