|
15 | 15 | use Symfony\Component\HttpKernel\Exception\HttpException; |
16 | 16 | use Pterodactyl\Exceptions\Repository\RecordNotFoundException; |
17 | 17 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
| 18 | +use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; |
18 | 19 |
|
19 | 20 | class Handler extends ExceptionHandler |
20 | 21 | { |
@@ -153,6 +154,26 @@ public function render($request, Exception $exception) |
153 | 154 | $connections->rollBack(0); |
154 | 155 | } |
155 | 156 |
|
| 157 | + // Because of some breaking change snuck into a Laravel update that didn't get caught |
| 158 | + // by any of the tests, exceptions implementing the HttpExceptionInterface get marked |
| 159 | + // as being HttpExceptions, but aren't actually implementing the HttpException abstract. |
| 160 | + // |
| 161 | + // This is incredibly annoying because we can't just temporarily override the handler to |
| 162 | + // allow these (at least without taking on a high maintenance cost). Laravel 5.8 fixes this, |
| 163 | + // so when we update (or have updated) this code can be removed. |
| 164 | + // |
| 165 | + // @see https://github.com/laravel/framework/pull/25975 |
| 166 | + // @todo remove this code when upgrading to Laravel 5.8 |
| 167 | + if ($exception instanceof HttpExceptionInterface && ! $exception instanceof HttpException) { |
| 168 | + $exception = new HttpException( |
| 169 | + $exception->getStatusCode(), |
| 170 | + $exception->getMessage(), |
| 171 | + $exception, |
| 172 | + $exception->getHeaders(), |
| 173 | + $exception->getCode() |
| 174 | + ); |
| 175 | + } |
| 176 | + |
156 | 177 | return parent::render($request, $exception); |
157 | 178 | } |
158 | 179 |
|
|
0 commit comments