|
6 | 6 | namespace App\Exceptions;
|
7 | 7 |
|
8 | 8 | use App\Libraries\SessionVerification;
|
9 |
| -use Auth; |
10 | 9 | use Illuminate\Auth\Access\AuthorizationException as LaravelAuthorizationException;
|
11 | 10 | use Illuminate\Auth\AuthenticationException;
|
12 | 11 | use Illuminate\Database\Eloquent\ModelNotFoundException;
|
@@ -34,6 +33,7 @@ class Handler extends ExceptionHandler
|
34 | 33 | ModelNotFoundException::class,
|
35 | 34 | TokenMismatchException::class,
|
36 | 35 | \Illuminate\Validation\ValidationException::class,
|
| 36 | + \Laravel\Octane\Exceptions\DdException::class, |
37 | 37 | \Symfony\Component\HttpKernel\Exception\HttpException::class,
|
38 | 38 |
|
39 | 39 | // local
|
@@ -90,6 +90,15 @@ private static function isOAuthSessionException(Throwable $e): bool
|
90 | 90 | && $e->getMessage() === 'Authorization request was not present in the session.';
|
91 | 91 | }
|
92 | 92 |
|
| 93 | + private static function reportWithSentry(Throwable $e): void |
| 94 | + { |
| 95 | + $ref = log_error_sentry($e, ['http_code' => (string) static::statusCode($e)]); |
| 96 | + |
| 97 | + if ($ref !== null) { |
| 98 | + \Request::instance()->attributes->set('ref', $ref); |
| 99 | + } |
| 100 | + } |
| 101 | + |
93 | 102 | private static function unwrapViewException(Throwable $e): Throwable
|
94 | 103 | {
|
95 | 104 | if ($e instanceof ViewException) {
|
@@ -121,10 +130,7 @@ public function report(Throwable $e)
|
121 | 130 | return;
|
122 | 131 | }
|
123 | 132 |
|
124 |
| - // Fallback in case error happening before config is initialised |
125 |
| - if ($GLOBALS['cfg']['sentry']['dsn'] ?? false) { |
126 |
| - $this->reportWithSentry($e); |
127 |
| - } |
| 133 | + static::reportWithSentry($e); |
128 | 134 |
|
129 | 135 | parent::report($e);
|
130 | 136 | }
|
@@ -196,25 +202,4 @@ protected function unauthenticated($request, AuthenticationException $exception)
|
196 | 202 |
|
197 | 203 | return ext_view('users.login', null, null, 401);
|
198 | 204 | }
|
199 |
| - |
200 |
| - private function reportWithSentry($e) |
201 |
| - { |
202 |
| - if (Auth::check()) { |
203 |
| - $userContext = [ |
204 |
| - 'id' => Auth::user()->user_id, |
205 |
| - 'username' => Auth::user()->username_clean, |
206 |
| - ]; |
207 |
| - } else { |
208 |
| - $userContext = [ |
209 |
| - 'id' => null, |
210 |
| - ]; |
211 |
| - } |
212 |
| - |
213 |
| - app('sentry')->configureScope(function ($scope) use ($e, $userContext) { |
214 |
| - $scope->setUser($userContext); |
215 |
| - $scope->setTag('http_code', (string) static::statusCode($e)); |
216 |
| - }); |
217 |
| - |
218 |
| - request()->attributes->set('ref', app('sentry')->captureException($e)); |
219 |
| - } |
220 | 205 | }
|
0 commit comments