...
In regards to combining those two lines, the 'unless stated otherwise by this document' part is not referring to the subclassing of ErrorException, but to the fact that the handler must not throw an exception for deprecation messages, and when error suppression is active. To combine them would result in something like:'The error handler MUST throw an exception of type ErrorException, or a subclass of ErrorException, unless stated otherwise by this document.'which I think is more confusing, as it's unclear to which part the 'unless' portion refers. It could be interpreted to mean that the spec allows for a completely different exception class in some circumstances, which is not the case.
Hi.
> Exceptions thrown MUST be of type \ErrorException or a subclass thereof.
For me, an exception is *always* an error. It is an exceptional case, something that should never happen. So, an exception subclasss \Exception (who’d have thought) is enough, IMHO.
Could you give an example[1] of when an exception is not an error?
Hi.
For me, an exception is *always* an error. It is an exceptional case, something that should never happen. So, an exception subclasss \Exception (who’d have thought) is enough, IMHO.
> Exceptions thrown MUST be of type \ErrorException or a subclass thereof.
Could you give an example[1] of when an exception is not an error?
Regards,
Karsten
[1] Yes, we have https://git.typo3.org/Packages/TYPO3.Flow.git/blob/HEAD:/Classes/TYPO3/Flow/Mvc/Exception/StopActionException.php but that is the only exception to the "\Exception rule” I can come up with, and we would use something else if we had a clever idea.
E_RECOVERABLE and E_USER_ERROR are special in that they are considered fatal by the native PHP error handler, even when @-silenced.
Thus, the only viable option for a user error handler is to always throw an exception for these two types, no matters the error_reporting() nor anything else.
This strategy would ensure that code paths are correct, but also that the application can continue if it decides to handle the exception.