A 3rd party library I'm using uses the @ error suppression operator in its codes which causes suppressed errors via @ still cause an error output because I am using a custom error handler (set_error_handler())
.
In this page it says
If you have set a custom error handler function with set_error_handler() then it will still get called, but this custom error handler can (and should) call error_reporting() which will return 0 when the call that triggered the error was preceded by an @.
However it is unclear how exactly can I catch the errors that was preceded by an @.
My question is how can I catch errors that was suppressed via @?
Answer
As it says: your error handler will still be invoked as usual, but calling error_reporting()
inside your error handler will yield 0
if the error was produced in the context of an @
. So your error handler should take that into account and act accordingly.
No comments:
Post a Comment