|
|
|
|
@ -192,7 +192,7 @@ final class ErrorHandler |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function isJsonRequest(): bool |
|
|
|
|
public function isJsonRequest(): bool |
|
|
|
|
{ |
|
|
|
|
$accept = $_SERVER['HTTP_ACCEPT'] ?? ''; |
|
|
|
|
$contentType = $_SERVER['CONTENT_TYPE'] ?? ''; |
|
|
|
|
@ -222,7 +222,7 @@ final class ErrorHandler |
|
|
|
|
return $trace; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function setJsonHeaders(int $status_code = 500): void |
|
|
|
|
public function setJsonHeaders(int $status_code = 500): void |
|
|
|
|
{ |
|
|
|
|
if (!headers_sent()) { |
|
|
|
|
/* |
|
|
|
|
@ -238,10 +238,15 @@ final class ErrorHandler |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function renderJsonDebug(Throwable $e): void |
|
|
|
|
{ |
|
|
|
|
echo $this->getJsonDebug($e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getJsonDebug(Throwable $e): string |
|
|
|
|
{ |
|
|
|
|
$this->setJsonHeaders(); |
|
|
|
|
|
|
|
|
|
echo json_encode([ |
|
|
|
|
return json_encode([ |
|
|
|
|
'error' => [ |
|
|
|
|
'type' => $this->getErrorType($e), |
|
|
|
|
'message' => $e->getMessage(), |
|
|
|
|
@ -297,7 +302,7 @@ final class ErrorHandler |
|
|
|
|
echo $color . $out . PHP_EOL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function formatWebMessage(Throwable $e): string |
|
|
|
|
public function formatWebMessage(Throwable $e): string |
|
|
|
|
{ |
|
|
|
|
$styles = [ |
|
|
|
|
'error' => 'uk-alert-danger', |
|
|
|
|
@ -325,7 +330,8 @@ final class ErrorHandler |
|
|
|
|
return $msg; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function renderProdMessage(): string { |
|
|
|
|
public function getProdMessage(): string |
|
|
|
|
{ |
|
|
|
|
if (Console::isConsole()) { |
|
|
|
|
return $this->myErr; |
|
|
|
|
} |
|
|
|
|
|