Everyone here should know the \'or\' statemens, usually glued to an die() command:
$foo = bar() or die(\'Error: bar function return false.\');
I've simply defined the function toss
for this.
function toss(Exception $exception): void
{
throw $exception;
}
Because the file/line/stack information is captured when the exception is constructed (new
) not thrown (throw
) this doesn't interfere with the call stack.
So you can just do this.
something() or toss(new Exception('something failed'));