reactphp / socket

Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP.
https://reactphp.org/socket/
MIT License
1.2k stars 156 forks source link

Improve error reporting when custom error handler is used #290

Closed clue closed 2 years ago

clue commented 2 years ago

This changeset improves error reporting when custom error handler is used (set_error_handler()). In particular, a global error handler may interrupt our code flow and unset the error reported to us (#286). The updated logic makes sure to set a custom error handler before invoking any functions that may report an error and restore the original error handler afterwards.

The gist is that using error_get_last() in library code is almost always broken and should be avoided: https://twitter.com/another_clue/status/1503830137132957696 and https://github.com/thecodingmachine/safe/issues/332

Resolves / closes #286 Builds on top of #266, #267, #269, #168, and others Also refs https://github.com/reactphp/event-loop/pull/245