Skip to content

Commit 5218769

Browse files
committed
Merge pull request #655 from entering/exception-controller-statuscode-fallback-msg
On ExceptionController getExceptionMessage() fallback to error
2 parents d68b4d5 + b95bdb9 commit 5218769

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Controller/ExceptionController.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,13 @@ 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()
177-
? $exception->getMessage()
178-
: Response::$statusTexts[$this->getStatusCode($exception)];
176+
if ($showExceptionMessage || $this->container->get('kernel')->isDebug()) {
177+
return $exception->getMessage();
178+
}
179+
180+
$statusCode = $this->getStatusCode($exception);
181+
182+
return array_key_exists($statusCode, Response::$statusTexts) ? Response::$statusTexts[$statusCode] : 'error';
179183
}
180184

181185
/**

0 commit comments

Comments
 (0)