Modified Silex provider to use HttpException status codes

If the exception does not have HttpException in its inheritance tree, the current value of 500 will be used as a fallback.
This commit is contained in:
Matthew Turland
2014-08-28 10:31:38 -05:00
parent e1d4394030
commit ea032d84af
@@ -11,6 +11,7 @@ use Silex\ServiceProviderInterface;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use RuntimeException;
class WhoopsServiceProvider implements ServiceProviderInterface
@@ -82,8 +83,9 @@ class WhoopsServiceProvider implements ServiceProviderInterface
ob_start();
$app['whoops']->$method($e);
$response = ob_get_clean();
$code = $e instanceof HttpException ? $e->getStatusCode() : 500;
return new Response($response, 500);
return new Response($response, $code);
});
$app['whoops']->register();