Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
902c3748
Commit
902c3748
authored
Jul 31, 2012
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added a note in the docs
parent
791ad2a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
doc/usage.rst
doc/usage.rst
+11
-2
No files found.
doc/usage.rst
View file @
902c3748
...
...
@@ -522,7 +522,7 @@ takes an ``Exception`` argument and returns a response::
use Symfony\Component\HttpFoundation\Response;
$app->error(function (\Exception $e, $code) {
return new Response('We are sorry, but something went terribly wrong.'
, $code
);
return new Response('We are sorry, but something went terribly wrong.');
});
You can also check for specific errors by using the ``$code`` argument, and
...
...
@@ -539,9 +539,18 @@ handle them differently::
$message = 'We are sorry, but something went terribly wrong.';
}
return new Response($message
, $code
);
return new Response($message);
});
.. note::
As Silex ensures that the Response status code is set to the most
appropriate one depending on the exception, setting the status on the
response won't work. If you want to overwrite the status code (which you
should not without a good reason), set the ``X-Status-Code`` header::
return new Response('Error', 404 /* ignored */, array('X-Status-Code' => 200));
You can restrict an error handler to only handle some Exception classes by
setting a more specific type hint for the Closure argument::
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment