Methods of EventEmitters should not throw Errors but emit error events instead.
On top of being the recommended way to throw errors in EventEmitters,
this is needed to be able to handle thoose errors.
Some errors may happen randomly or may be due to external sources (server or libraries).
A typical usecase is forwarding http/2 requests and response (thoose can contains minor errors like deprecated headers or invalid frame or whatever and it should not crash the server ...)
Currently thoose errors are not catchable (because they are thrown from asynchronous or nested methods).
Emiting error event allow to handle errors (by listening to error event) while keeping the original behavior (throwing error) if error event is not listened to
Methods of EventEmitters should not throw Errors but emit error events instead. On top of being the recommended way to throw errors in EventEmitters, this is needed to be able to handle thoose errors. Some errors may happen randomly or may be due to external sources (server or libraries). A typical usecase is forwarding http/2 requests and response (thoose can contains minor errors like deprecated headers or invalid frame or whatever and it should not crash the server ...)
Currently thoose errors are not catchable (because they are thrown from asynchronous or nested methods). Emiting error event allow to handle errors (by listening to error event) while keeping the original behavior (throwing error) if error event is not listened to
This PR apply this for a few errors.