Commit 46f125c4 authored by Poisbeau Mathieu's avatar Poisbeau Mathieu

Update "Error Handlers" part in usage.rst

Update "Error Handlers" part in usage.rst because of https://github.com/silexphp/Silex/commit/e96f9be8fda96193313bb655d63b061d6d4d7c4d#diff-9460b640f6466d5890f37f7caf262024R52
parent 0328d904
......@@ -517,8 +517,9 @@ To register an error handler, pass a closure to the ``error`` method which
takes an ``Exception`` argument and returns a response::
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
$app->error(function (\Exception $e, $code) {
$app->error(function (\Exception $e, Request $request, $code) {
return new Response('We are sorry, but something went terribly wrong.');
});
......@@ -526,8 +527,9 @@ You can also check for specific errors by using the ``$code`` argument, and
handle them differently::
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
$app->error(function (\Exception $e, $code) {
$app->error(function (\Exception $e, Request $request, $code) {
switch ($code) {
case 404:
$message = 'The requested page could not be found.';
......@@ -551,7 +553,9 @@ handle them differently::
You can restrict an error handler to only handle some Exception classes by
setting a more specific type hint for the Closure argument::
$app->error(function (\LogicException $e, $code) {
use Symfony\Component\HttpFoundation\Request;
$app->error(function (\LogicException $e, Request $request, $code) {
// this handler will only handle \LogicException exceptions
// and exceptions that extends \LogicException
});
......@@ -574,8 +578,9 @@ once a response is returned, the following handlers are ignored.
is turned on like this::
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
$app->error(function (\Exception $e, $code) use ($app) {
$app->error(function (\Exception $e, Request $request, $code) use ($app) {
if ($app['debug']) {
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