Skip to content

Commit 746f99b

Browse files
committed
At Exception controller if not defined show exception message or debug show status code message instead of empty message
1 parent c7adf7b commit 746f99b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Controller/ExceptionController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ protected function getExceptionMessage($exception)
173173
$exceptionMap = $this->container->getParameter('fos_rest.exception.messages');
174174
$showExceptionMessage = $this->isSubclassOf($exception, $exceptionMap);
175175

176-
return $showExceptionMessage || $this->container->get('kernel')->isDebug() ? $exception->getMessage() : '';
176+
return $showExceptionMessage || $this->container->get('kernel')->isDebug()
177+
? $exception->getMessage()
178+
: Response::$statusTexts[$this->getStatusCode($exception)];
177179
}
178180

179181
/**
@@ -186,7 +188,7 @@ protected function getExceptionMessage($exception)
186188
protected function getStatusCode($exception)
187189
{
188190
$exceptionMap = $this->container->getParameter('fos_rest.exception.codes');
189-
$isExceptionMappedToStatusCode = $this->isSubclassOf($exception, $exceptionMap);;
191+
$isExceptionMappedToStatusCode = $this->isSubclassOf($exception, $exceptionMap);
190192

191193
return ($isExceptionMappedToStatusCode) ? $isExceptionMappedToStatusCode : $exception->getStatusCode();
192194
}

0 commit comments

Comments
 (0)