Home > @wixc3/common > ErrorWithCode
Creates an error with error code. Helpful when instanceof
can’t be used because the error was serialized and then deserialized.
Signature:
export declare class ErrorWithCode extends Error
Extends: Error
try {
throw new ErrorWithCode('message', { code: 'ENOENT' });
} catch (error) {
if (getErrorCode(toError(error)) === 'ENOENT') {
// ...
}
}
Constructor | Modifiers | Description |
---|---|---|
[(constructor)(message, options)](/core3-utils/common.errorwithcode._constructor_.html) | Constructs a new instance of the `ErrorWithCode` class |
Property | Modifiers | Type | Description |
---|---|---|---|
[code?](/core3-utils/common.errorwithcode.code.html) | string | _(Optional)_ |