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
8aa9807a
Commit
8aa9807a
authored
May 20, 2012
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed exception handling when an exception is thrown in the before filter (closes #260)
parent
c959ea3f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
src/Silex/Application.php
src/Silex/Application.php
+6
-1
tests/Silex/Tests/BeforeAfterFilterTest.php
tests/Silex/Tests/BeforeAfterFilterTest.php
+12
-1
No files found.
src/Silex/Application.php
View file @
8aa9807a
...
@@ -550,7 +550,12 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
...
@@ -550,7 +550,12 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
{
{
if
(
!
$this
->
beforeDispatched
)
{
if
(
!
$this
->
beforeDispatched
)
{
$this
->
beforeDispatched
=
true
;
$this
->
beforeDispatched
=
true
;
try
{
$this
[
'dispatcher'
]
->
dispatch
(
SilexEvents
::
BEFORE
,
$event
);
$this
[
'dispatcher'
]
->
dispatch
(
SilexEvents
::
BEFORE
,
$event
);
}
catch
(
\Exception
$e
)
{
// as we are already handling an exception, ignore this one
// even if it might have been thrown on purpose by the developer
}
}
}
$errorEvent
=
new
GetResponseForErrorEvent
(
$this
,
$event
->
getRequest
(),
$event
->
getRequestType
(),
$event
->
getException
());
$errorEvent
=
new
GetResponseForErrorEvent
(
$this
,
$event
->
getRequest
(),
$event
->
getRequestType
(),
$event
->
getException
());
...
...
tests/Silex/Tests/BeforeAfterFilterTest.php
View file @
8aa9807a
...
@@ -163,7 +163,18 @@ class BeforeAfterFilterTest extends \PHPUnit_Framework_TestCase
...
@@ -163,7 +163,18 @@ class BeforeAfterFilterTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
2
,
$i
);
$this
->
assertEquals
(
2
,
$i
);
}
}
public
function
testRequestShouldBePopulatedOnBefore
()
{
public
function
testBeforeFilterExceptionsWhenHandlingAnException
()
{
$app
=
new
Application
();
$app
->
before
(
function
()
{
throw
new
\RuntimeException
(
''
);
});
// even if the before filter throws an exception, we must have the 404
$this
->
assertEquals
(
404
,
$app
->
handle
(
Request
::
create
(
'/'
))
->
getStatusCode
());
}
public
function
testRequestShouldBePopulatedOnBefore
()
{
$app
=
new
Application
();
$app
=
new
Application
();
$app
->
before
(
function
()
use
(
$app
)
{
$app
->
before
(
function
()
use
(
$app
)
{
...
...
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