@@ -65,7 +65,12 @@ public function __construct(
6565 public function showAction (Request $ request , $ exception , DebugLoggerInterface $ logger = null )
6666 {
6767 $ currentContent = $ this ->getAndCleanOutputBuffering ($ request ->headers ->get ('X-Php-Ob-Level ' , -1 ));
68- $ code = $ this ->getStatusCode ($ exception );
68+
69+ if ($ exception instanceof \Exception) {
70+ $ code = $ this ->getStatusCode ($ exception );
71+ } else {
72+ $ code = $ this ->getStatusCodeFromThrowable ($ exception );
73+ }
6974 $ templateData = $ this ->getTemplateData ($ currentContent , $ code , $ exception , $ logger );
7075
7176 $ view = $ this ->createView ($ exception , $ code , $ templateData , $ request , $ this ->showException );
@@ -101,17 +106,7 @@ protected function createView(\Exception $exception, $code, array $templateData,
101106 */
102107 protected function getStatusCode (\Exception $ exception )
103108 {
104- // If matched
105- if ($ statusCode = $ this ->exceptionCodes ->resolveException ($ exception )) {
106- return $ statusCode ;
107- }
108-
109- // Otherwise, default
110- if ($ exception instanceof HttpExceptionInterface) {
111- return $ exception ->getStatusCode ();
112- }
113-
114- return 500 ;
109+ return $ this ->getStatusCodeFromThrowable ($ exception );
115110 }
116111
117112 /**
@@ -159,4 +154,26 @@ private function getAndCleanOutputBuffering($startObLevel)
159154
160155 return ob_get_clean ();
161156 }
157+
158+ /**
159+ * Determines the status code to use for the response.
160+ *
161+ * @param \Throwable $exception
162+ *
163+ * @return int
164+ */
165+ private function getStatusCodeFromThrowable (\Throwable $ exception )
166+ {
167+ // If matched
168+ if ($ statusCode = $ this ->exceptionCodes ->resolveThrowable ($ exception )) {
169+ return $ statusCode ;
170+ }
171+
172+ // Otherwise, default
173+ if ($ exception instanceof HttpExceptionInterface) {
174+ return $ exception ->getStatusCode ();
175+ }
176+
177+ return 500 ;
178+ }
162179}
0 commit comments