$this->_debug => $this->debug
This commit is contained in:
parent
17bf447521
commit
da879d3c68
@ -27,13 +27,14 @@ class Handler extends \support\exception\Handler
|
|||||||
public function render(Request $request, Throwable $exception): Response
|
public function render(Request $request, Throwable $exception): Response
|
||||||
{
|
{
|
||||||
$code = $exception->getCode();
|
$code = $exception->getCode();
|
||||||
|
$debug = $this->_debug ?? $this->debug;
|
||||||
if ($request->expectsJson()) {
|
if ($request->expectsJson()) {
|
||||||
$json = ['code' => $code ? $code : 500, 'msg' => $this->_debug ? $exception->getMessage() : 'Server internal error', 'type' => 'failed'];
|
$json = ['code' => $code ?: 500, 'msg' => $debug ? $exception->getMessage() : 'Server internal error', 'type' => 'failed'];
|
||||||
$this->_debug && $json['traces'] = (string)$exception;
|
$debug && $json['traces'] = (string)$exception;
|
||||||
return new Response(200, ['Content-Type' => 'application/json'],
|
return new Response(200, ['Content-Type' => 'application/json'],
|
||||||
\json_encode($json, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
\json_encode($json, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||||
}
|
}
|
||||||
$error = $this->_debug ? \nl2br((string)$exception) : 'Server internal error';
|
$error = $debug ? \nl2br((string)$exception) : 'Server internal error';
|
||||||
return new Response(500, [], $error);
|
return new Response(500, [], $error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user