I have some code in a __destruct() method that sometimes throws an exception. The __destruct() method is being called during another exception and I'm seeing a vague error:
PHP Fatal error: Ignoring exception from exampleClass::__destruct() while an exception is already active
which is hiding the actual exception that's being called. I'd like to do something like:
public function __destruct()
{
try
{
// do work here
}
catch(Exception $e)
{
// check if we're already in an exception and log it
if(already_in_exception())
{
error_log($e->getMessage());
}
// normal destruct, re-throw
else
{
throw $e;
}
}
}
Bonus points if it's PHP 5.1.6 compatible!
Thank you in advanced!