111
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Server;
|
||||
|
||||
use Server\Constrict\Response;
|
||||
use Server\Constrict\Response as CResponse;
|
||||
use Server\Message\Stream;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
@@ -14,22 +15,22 @@ class ExceptionHandlerDispatcher implements ExceptionHandlerInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param Throwable $exception
|
||||
* @param CResponse $response
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function emit(Throwable $exception, Response $response): ResponseInterface
|
||||
{
|
||||
if ($exception->getCode() == 404) {
|
||||
return $response->setContent($exception->getMessage())
|
||||
->setFormat(CResponse::HTML)
|
||||
->setStatusCode(404);
|
||||
}
|
||||
$code = $exception->getCode() == 0 ? 500 : $exception->getCode();
|
||||
return $response->setContent(jTraceEx($exception, null, true))
|
||||
->setFormat(CResponse::HTML)
|
||||
->setStatusCode($code);
|
||||
}
|
||||
/**
|
||||
* @param Throwable $exception
|
||||
* @param CResponse $response
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function emit(Throwable $exception, Response $response): ResponseInterface
|
||||
{
|
||||
if ($exception->getCode() == 404) {
|
||||
return $response->withBody(new Stream($exception->getMessage()))
|
||||
->withHeader('Content-Type', 'text/html')
|
||||
->withStatus(404);
|
||||
}
|
||||
$code = $exception->getCode() == 0 ? 500 : $exception->getCode();
|
||||
return $response->withBody(new Stream(jTraceEx($exception, null, true)))
|
||||
->withHeader('Content-Type', 'text/html')
|
||||
->withStatus($code);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user