From 1dc8d2e59c68794c177933b47eb1ca096e218d47 Mon Sep 17 00:00:00 2001 From: Orka Arnest CRUZE Date: Thu, 23 Nov 2023 16:49:48 +0100 Subject: [PATCH] fix: petite correction statusText --- src/Listener/CartesApiExceptionSubscriber.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Listener/CartesApiExceptionSubscriber.php b/src/Listener/CartesApiExceptionSubscriber.php index 42a3e338..17c5229c 100644 --- a/src/Listener/CartesApiExceptionSubscriber.php +++ b/src/Listener/CartesApiExceptionSubscriber.php @@ -39,12 +39,14 @@ public function onCartesApiException(ExceptionEvent $event): void } } + /** + * @SuppressWarnings(UndefinedVariable) + */ private function getErrorResponse(CartesApiException $throwable): JsonResponse { - $statusText = 'Internal Server Error'; $responseData = [ 'code' => Response::HTTP_INTERNAL_SERVER_ERROR, - 'status' => $statusText, + 'status' => Response::$statusTexts[Response::HTTP_INTERNAL_SERVER_ERROR], 'message' => 'An internal error has occurred', 'details' => [], ]; @@ -52,7 +54,8 @@ private function getErrorResponse(CartesApiException $throwable): JsonResponse if ($throwable instanceof CartesApiException) { $code = $throwable->getCode(); $responseData['code'] = $code; - $responseData['status'] = $statusText; + + $responseData['status'] = Response::$statusTexts[$code]; $responseData['message'] = $throwable->getMessage(); $responseData['details'] = $throwable->getDetails(); }