Bläddra i källkod

[HttpKernel] fixed error message in HttpKernel

Fabien Potencier 14 år sedan
förälder
incheckning
d96c152c4c
1 ändrade filer med 11 tillägg och 5 borttagningar
  1. 11 5
      src/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php

+ 11 - 5
src/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php

@@ -74,10 +74,12 @@ class ExceptionHandler
             $code = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500;
             $exception = FlattenException::create($exception);
 
-            if (404 == $code) {
-                $title = 'Sorry, the page you are looking for could not be found.';
-            } else {
-                $title = 'Whoops, looks like something went wrong.';
+            switch($code) {
+                case 404:
+                    $title = 'Sorry, the page you are looking for could not be found.';
+                    break;
+                default:
+                    $title = 'Whoops, looks like something went wrong.';
             }
 
             if ($this->debug) {
@@ -85,7 +87,11 @@ class ExceptionHandler
             }
         } catch (\Exception $e) {
             // something nasty happened and we cannot throw an exception here anymore
-            $title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($exception), $exception->getMessage());
+            if ($this->debug) {
+                $title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($exception), $exception->getMessage());
+            } else {
+                $title = 'Whoops, looks like something went wrong.';
+            }
         }
 
         return new Response($this->decorate($content, $title), $code);