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
b3fc523b
Commit
b3fc523b
authored
May 21, 2012
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed exception handling
parent
cb5003a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
src/Silex/Application.php
src/Silex/Application.php
+6
-3
tests/Silex/Tests/ErrorHandlerTest.php
tests/Silex/Tests/ErrorHandlerTest.php
+6
-6
No files found.
src/Silex/Application.php
View file @
b3fc523b
...
...
@@ -309,16 +309,19 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
$this
[
'dispatcher'
]
->
addListener
(
SilexEvents
::
ERROR
,
function
(
GetResponseForErrorEvent
$event
)
use
(
$callback
)
{
$exception
=
$event
->
getException
();
if
(
is_array
(
$callback
))
{
if
(
is_array
(
$callback
))
{
$callbackReflection
=
new
\ReflectionMethod
(
$callback
[
0
],
$callback
[
1
]);
}
elseif
(
is_object
(
$callback
)
&&
!
$callback
instanceof
\Closure
)
{
$callbackReflection
=
new
\ReflectionObject
(
$callback
);
$callbackReflection
=
$callbackReflection
->
getMethod
(
'__invoke'
);
}
else
{
$callbackReflection
=
new
\ReflectionFunction
(
$callback
);
}
if
(
$callbackReflection
->
getNumberOfParameters
()
>
0
)
{
if
(
$callbackReflection
->
getNumberOfParameters
()
>
0
)
{
$parameters
=
$callbackReflection
->
getParameters
();
$expectedException
=
$parameters
[
0
];
if
(
$expectedException
->
getClass
()
&&
!
(
$expectedException
->
getClass
()
->
isInstance
(
$exception
)))
{
if
(
$expectedException
->
getClass
()
&&
!
$expectedException
->
getClass
()
->
isInstance
(
$exception
))
{
return
;
}
}
...
...
tests/Silex/Tests/ErrorHandlerTest.php
View file @
b3fc523b
...
...
@@ -345,13 +345,8 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
throw
new
\Exception
();
});
$stub
=
$this
->
getMock
(
'\StdClass'
);
$stub
->
expects
(
$this
->
any
())
->
method
(
'handler'
)
->
will
(
$this
->
returnValue
(
'Caught Exception'
));
// Array style callback for error handler
$app
->
error
(
array
(
$
stub
,
'h
andler'
));
$app
->
error
(
array
(
$
this
,
'exceptionH
andler'
));
$request
=
Request
::
create
(
'/foo'
);
$response
=
$app
->
handle
(
$request
);
...
...
@@ -366,4 +361,9 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
return
$response
;
}
public
function
exceptionHandler
()
{
return
'Caught Exception'
;
}
}
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