Builds a new error object, linking it to the original error via the cause
property if it is an Error.
This function is useful to reframe error messages in general, but is
critical when interacting with any of Node's filesystem functions as
provided via fs.promises, because these do not produce stack traces in the
case of an I/O error (see https://github.com/nodejs/node/issues/30944).
Builds a new error object, linking it to the original error via the
cause
property if it is an Error.This function is useful to reframe error messages in general, but is critical when interacting with any of Node's filesystem functions as provided via
fs.promises
, because these do not produce stack traces in the case of an I/O error (see https://github.com/nodejs/node/issues/30944).Returns
A new error object.