Hi,
Reading this as a PHP dev is confusing (terminology-wise) because errors
used to be the fatal ("stop the world") conditions while exceptions were the
catchable, recovarable issues within some call - feels to me pretty
equivalent to what you're proposing here.
What's the problem with PHP exceptions? I'm not even trying to argue, I'm
trying to understand. Is it the implementation (bad/expensive performance)?
Semantics? Handling syntax?
I didn't understand the bubbling changes either. What do you mean by
"fatal"? Does it turn the raised "light error" into a real exception? Or
does it turn into an actual error crashing the whole process?
function div(int $n, int $d): float raises ZeroDivisor
{
if (!$d)
raise new ZeroDivisor;
return $n/$d;
}
function inverse(int $x): float
{
// does not handle the raise
return div(1, $x);
}
// assuming the above functions are in a lib, can i rescue this using
some trycatch or not?
inverse($_GET['x']);
And if I don't rescue, am I supposed to see that I passed a bad value to
inverse
, a bad value to div
or just that inverse
failed to
handle a
raise?
BR,
Juris