Unverified Commit d57a2421 authored by Ruben Bridgewater's avatar Ruben Bridgewater Committed by Myles Borins
Browse files

errors: implement new error handling

This implements a function based system. Instead of passing in the
error code as first argument, the error code itself is a error class.
It already contains the correct error type, so while adding a new
error no one has to think about the error type anymore. In case a
single error code has more than one error type, the error class has
properties for the non default error types. Those can be used as
fallback.

This prevents typos, makes the implementation easier and it is less
verbose when writing the code for a new error.

The implementation itself does not interfere with the old
implementation. So the old and the new system can co-exist and it is
possible to slowly migrate the old ones to the new system.

Backport-PR-URL: https://github.com/nodejs/node/pull/19244
PR-URL: https://github.com/nodejs/node/pull/18857


Reviewed-By: default avatarAnna Henningsen <anna@addaleax.net>
Reviewed-By: default avatarGus Caplan <me@gus.host>
Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
Reviewed-By: default avatarJoyee Cheung <joyeec9h3@gmail.com>
parent cb732aed
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment