Skip to content

Commit

Permalink
Get correct error code when exception happens. Fixes #733 #751
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnieezell committed Oct 8, 2017
1 parent 1493512 commit 6af5f1f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions system/Debug/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
* @since Version 3.0.0
* @filesource
*/
require __DIR__ . '/CustomExceptions.php';
use Config\Services;

require __DIR__.'/CustomExceptions.php';

/**
* Exceptions manager
Expand Down Expand Up @@ -108,7 +110,6 @@ public function exceptionHandler(\Throwable $exception)
$codes = $this->determineCodes($exception);
$code = $codes[0];
$exit = $codes[1];
$code = $exception->getCode();
$message = $exception->getMessage();
$file = $exception->getFile();
$line = $exception->getLine();
Expand All @@ -122,6 +123,8 @@ public function exceptionHandler(\Throwable $exception)

// Log it
// Fire an Event

// Display the error
$templates_path = $this->viewPath;
if (empty($templates_path))
{
Expand All @@ -134,7 +137,9 @@ public function exceptionHandler(\Throwable $exception)
}
else
{
header('HTTP/1.1 500 Internal Server Error', true, 500);
$response = Services::response()->setStatusCode($code);
$header = "HTTP/1.1 {$response->getStatusCode()} {$response->getReason()}";
header($header, true, $code);
$templates_path .= 'html/';
}

Expand Down

0 comments on commit 6af5f1f

Please sign in to comment.