> ** > The overall mood seems to be that since PHP has an error handler, everyone > is free to handle errors any way they want. > 2) When everyone starts handling errors in their own way with error > handlers, you can't reliably use third party code. You are in your own > universe. >
I think that's the main point that makes any change to the way PHP currently handles errors difficult: The current behavior is to continue the execution flow (except for fatal errors of course) whereas an exception always breaks it. Throwing an exception, either in a custom or in a new internal handler, introduces a major portability + backward compatibility issue. But do you think it could be possible to introduce a per script declaration of the way it has been coded regarding error handling ? We could imagine for example that any script that is coded assuming exceptions instead of errors could be force to declare with a : <?php declare(throw_errors=1); ?> or maybe : <?php declare(throw_errors=E_WARNING | E_NOTICE /* | ...*/); > 1) PHP Errors come with a severity code and a string message. You want to > handle specific errors in a specific way? You better start writing giant > regexes parsing the string messages. > This is a problem that could also be addressed with the current error handling mechanism: that would require that any error comes with some unique number for example. Is this possible? Independently of the exception vs classical error discussion, that would be amazing. Regards, Nicolas