From abb9508c365d5ca81d8811556f027fb21ce6d8d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 10 Sep 2021 10:53:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http-server/ExceptionHandlerDispatcher.php | 13 +++++++------ http-server/ExceptionHandlerInterface.php | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/http-server/ExceptionHandlerDispatcher.php b/http-server/ExceptionHandlerDispatcher.php index b858a842..3a1e466d 100644 --- a/http-server/ExceptionHandlerDispatcher.php +++ b/http-server/ExceptionHandlerDispatcher.php @@ -4,9 +4,11 @@ namespace Server; use Server\Constrict\Response; -use Server\Constrict\Response as CResponse; -use Server\Message\Stream; +use Protocol\Message\Response as CResponse; use Throwable; +use Protocol\Message\Stream; +use Server\Constrict\ResponseInterface; + /** * @@ -17,20 +19,19 @@ class ExceptionHandlerDispatcher implements ExceptionHandlerInterface /** * @param Throwable $exception - * @param CResponse $response + * @param Response $response * @return ResponseInterface - * @throws \Exception */ public function emit(Throwable $exception, Response $response): ResponseInterface { if ($exception->getCode() == 404) { return $response->withBody(new Stream($exception->getMessage())) - ->withContentType(Message\Response::CONTENT_TYPE_HTML) + ->withContentType(CResponse::CONTENT_TYPE_HTML) ->withStatus(404); } $code = $exception->getCode() == 0 ? 500 : $exception->getCode(); return $response->withBody(new Stream(jTraceEx($exception, null, true))) - ->withContentType(Message\Response::CONTENT_TYPE_HTML) + ->withContentType(CResponse::CONTENT_TYPE_HTML) ->withStatus($code); } diff --git a/http-server/ExceptionHandlerInterface.php b/http-server/ExceptionHandlerInterface.php index c4f7409b..3ce7f55c 100644 --- a/http-server/ExceptionHandlerInterface.php +++ b/http-server/ExceptionHandlerInterface.php @@ -4,6 +4,7 @@ namespace Server; use Server\Constrict\Response; use Throwable; +use Server\Constrict\ResponseInterface; /** *