I'm trying to find right solution to catch messages but not sure if this is possible or no.
I have a simple PHP structure with try and catch:
if (!$this->issetAndNotEmpty($id))
{
throw new Exception('My error message');
}
...
catch (Exception $exc)
{
echo'<div class="error">'. $exc->getMessage().'</div>';
}
...
It works as supposed. But we have a requirement to return error noise(beep) on some errors (but not on all of them). Best way to do this is add new function into catch section. In this way it beeps every time.
Is it possible to add second parameter into throw new Exception('My error message', true(or something like that));
and then run this function under if statement?
Another way is to add variable inside class and set to true and check it inside catch before error message.
Is it possible to do that in first way?