Commit 4a79566e authored by Fabien Potencier's avatar Fabien Potencier

minor #1080 Closure in $app->error() takes 3 arguments (qpleple)

This PR was merged into the 2.0.x-dev branch.

Discussion
----------

Closure in $app->error() takes 3 arguments

see https://github.com/silexphp/Silex/blob/master/src/Silex/ExceptionListenerWrapper.php#L53

Commits
-------

c5528daa Closure in $app->error() takes 3 arguments
parents a19bf3ee c5528daa
...@@ -490,7 +490,7 @@ takes an ``Exception`` argument and returns a response:: ...@@ -490,7 +490,7 @@ takes an ``Exception`` argument and returns a response::
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
$app->error(function (\Exception $e, $code) { $app->error(function (\Exception $e, $request, $code) {
return new Response('We are sorry, but something went terribly wrong.'); return new Response('We are sorry, but something went terribly wrong.');
}); });
...@@ -499,7 +499,7 @@ handle them differently:: ...@@ -499,7 +499,7 @@ handle them differently::
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
$app->error(function (\Exception $e, $code) { $app->error(function (\Exception $e, $request, $code) {
switch ($code) { switch ($code) {
case 404: case 404:
$message = 'The requested page could not be found.'; $message = 'The requested page could not be found.';
...@@ -523,7 +523,7 @@ handle them differently:: ...@@ -523,7 +523,7 @@ handle them differently::
You can restrict an error handler to only handle some Exception classes by You can restrict an error handler to only handle some Exception classes by
setting a more specific type hint for the Closure argument:: setting a more specific type hint for the Closure argument::
$app->error(function (\LogicException $e, $code) { $app->error(function (\LogicException $e, $request, $code) {
// this handler will only handle \LogicException exceptions // this handler will only handle \LogicException exceptions
// and exceptions that extends \LogicException // and exceptions that extends \LogicException
}); });
...@@ -547,7 +547,7 @@ once a response is returned, the following handlers are ignored. ...@@ -547,7 +547,7 @@ once a response is returned, the following handlers are ignored.
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
$app->error(function (\Exception $e, $code) use ($app) { $app->error(function (\Exception $e, $request, $code) use ($app) {
if ($app['debug']) { if ($app['debug']) {
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment