You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No data received error in the browser when re-throwing the same caught exception in aop_add_after_throwing() and using getKindOfAdvice() inside the advice itself
#92
Open
tonix-tuft opened this issue
Mar 7, 2015
· 0 comments
<?php
aop_add_after_throwing("*->*()", function(AopJoinPoint $joinPoint) {
echo "Inside advice";
$e = $joinPoint->getException();
var_dump($e);
$type = $joinPoint->getKindOfAdvice();
var_dump("TYPE: " . $type);
});
class RiskyClass {
public function riskyInstanceOperation() {
//*
try
{
// do something risky
if (false) {
echo "succeeded";
}
else {
throw new Exception("Ooops!");
}
}
catch (Exception $e)
{
echo "Exception caught";
throw new Exception("But another thrown");
}
//*/
}
}
$obj = (new RiskyClass())->riskyInstanceOperation();
Works like expected, outputs Inside advice, the var_dump of the exception and the type of the advice: string 'TYPE: 324'
However, instead of throwing new Exception("But another thrown"); if I re-throw the same caught exception:
<?php
aop_add_after_throwing("*->*()", function(AopJoinPoint $joinPoint) {
echo "Inside advice";
$e = $joinPoint->getException();
var_dump($e);
$type = $joinPoint->getKindOfAdvice();
var_dump("TYPE: " . $type);
});
class RiskyClass {
public function riskyInstanceOperation() {
//*
try
{
// do something risky
if (false) {
echo "succeeded";
}
else {
throw new Exception("Ooops!");
}
}
catch (Exception $e)
{
echo "Exception caught";
throw $e; // re-throwing the same exception
}
//*/
}
}
$obj = (new RiskyClass())->riskyInstanceOperation();
No output is given and instead the following error appears in the browser:
No data received
Unable to load the webpage because the server sent no data.
Error code: ERR_EMPTY_RESPONSE
Server response is empty.
I found that it is something that has to do with $joinPoint->getKindOfAdvice();, therefore when the getKindOfAdvice() method is called, because if I comment these lines:
Hi,
The following code:
Works like expected, outputs
Inside advice
, thevar_dump
of the exception and the type of the advice: string 'TYPE: 324'However, instead of throwing
new Exception("But another thrown");
if I re-throw the same caught exception:No output is given and instead the following error appears in the browser:
Server response is empty.
I found that it is something that has to do with
$joinPoint->getKindOfAdvice();
, therefore when thegetKindOfAdvice()
method is called, because if I comment these lines:Inside the advice's callback and I refresh the browser, everything works even with re-thrown exception.
The text was updated successfully, but these errors were encountered: