diff --git a/src/ResponseBuilder.php b/src/ResponseBuilder.php index f03c96e..1a36e98 100644 --- a/src/ResponseBuilder.php +++ b/src/ResponseBuilder.php @@ -40,7 +40,7 @@ public function __construct(protected DataFormatterInterface $dataFormatter, pro { } - public function buildErrorResponse(ServerRequestInterface $request, int $code, Throwable $error = null): ResponsePlusInterface + public function buildErrorResponse(ServerRequestInterface $request, int $code, ?Throwable $error = null): ResponsePlusInterface { $body = new SwooleStream($this->formatErrorResponse($request, $code, $error)); return $this->response()->addHeader('content-type', 'application/json')->setBody($body); @@ -67,7 +67,7 @@ protected function formatResponse($response, ServerRequestInterface $request): s return $this->packer->pack($response); } - protected function formatErrorResponse(ServerRequestInterface $request, int $code, Throwable $error = null): string + protected function formatErrorResponse(ServerRequestInterface $request, int $code, ?Throwable $error = null): string { [$code, $message] = $this->error($code, $error?->getMessage()); $response = $this->dataFormatter->formatErrorResponse(