|
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\Exceptions\HTTPException;
|
@@ -312,18 +314,25 @@ protected function maskSensitiveData(&$trace, array $keysToMask, string $path =
|
312 | 314 | */
|
313 | 315 | protected function determineCodes(Throwable $exception): array
|
314 | 316 | {
|
315 |
| - $statusCode = abs($exception->getCode()); |
| 317 | + $statusCode = 500; |
| 318 | + $exitStatus = EXIT_ERROR; |
316 | 319 |
|
317 |
| - if ($statusCode < 100 || $statusCode > 599) { |
318 |
| - $exitStatus = $statusCode + EXIT__AUTO_MIN; |
| 320 | + // For backward compatibility. I don't think this process is necessary. |
| 321 | + $exceptionCode = abs($exception->getCode()); |
| 322 | + if ($exceptionCode < 100 || $exceptionCode > 599) { |
| 323 | + $exitStatus = $exceptionCode + EXIT__AUTO_MIN; |
319 | 324 |
|
320 | 325 | if ($exitStatus > EXIT__AUTO_MAX) {
|
321 | 326 | $exitStatus = EXIT_ERROR;
|
322 | 327 | }
|
| 328 | + } |
| 329 | + |
| 330 | + if ($exception instanceof HasHttpStatusCodeException) { |
| 331 | + $statusCode = $exception->getCode(); |
| 332 | + } |
323 | 333 |
|
324 |
| - $statusCode = 500; |
325 |
| - } else { |
326 |
| - $exitStatus = EXIT_ERROR; |
| 334 | + if ($exception instanceof HasExitCodeException) { |
| 335 | + $exitStatus = $exception->getCode(); |
327 | 336 | }
|
328 | 337 |
|
329 | 338 | return [$statusCode, $exitStatus];
|
|
0 commit comments