|
12 | 12 | namespace CodeIgniter\Debug;
|
13 | 13 |
|
14 | 14 | use CodeIgniter\API\ResponseTrait;
|
| 15 | +use CodeIgniter\Exceptions\HasExitCodeException; |
| 16 | +use CodeIgniter\Exceptions\HasHttpStatusCodeException; |
15 | 17 | use CodeIgniter\Exceptions\PageNotFoundException;
|
16 | 18 | use CodeIgniter\HTTP\CLIRequest;
|
17 | 19 | use CodeIgniter\HTTP\IncomingRequest;
|
@@ -304,18 +306,25 @@ protected function maskSensitiveData(&$trace, array $keysToMask, string $path =
|
304 | 306 | */
|
305 | 307 | protected function determineCodes(Throwable $exception): array
|
306 | 308 | {
|
307 |
| - $statusCode = abs($exception->getCode()); |
| 309 | + $statusCode = 500; |
| 310 | + $exitStatus = EXIT_ERROR; |
308 | 311 |
|
309 |
| - if ($statusCode < 100 || $statusCode > 599) { |
310 |
| - $exitStatus = $statusCode + EXIT__AUTO_MIN; |
| 312 | + // For backward compatibility. I don't think this process is necessary. |
| 313 | + $exceptionCode = abs($exception->getCode()); |
| 314 | + if ($exceptionCode < 100 || $exceptionCode > 599) { |
| 315 | + $exitStatus = $exceptionCode + EXIT__AUTO_MIN; |
311 | 316 |
|
312 | 317 | if ($exitStatus > EXIT__AUTO_MAX) {
|
313 | 318 | $exitStatus = EXIT_ERROR;
|
314 | 319 | }
|
| 320 | + } |
| 321 | + |
| 322 | + if ($exception instanceof HasHttpStatusCodeException) { |
| 323 | + $statusCode = $exception->getCode(); |
| 324 | + } |
315 | 325 |
|
316 |
| - $statusCode = 500; |
317 |
| - } else { |
318 |
| - $exitStatus = EXIT_ERROR; |
| 326 | + if ($exception instanceof HasExitCodeException) { |
| 327 | + $exitStatus = $exception->getCode(); |
319 | 328 | }
|
320 | 329 |
|
321 | 330 | return [$statusCode, $exitStatus];
|
|
0 commit comments