@w5s/error
W5S Error module (@w5s/error)
Installation
npm install @w5s/error
Usage
import { CustomError, Error, TypeError } from '@w5s/error';
export interface MyError
extends CustomError<{
name: 'MyError';
foo: string;
bar: boolean;
}> {}
export const MyError = CustomError.define<MyError>({ errorName: 'MyError' });
const myError = MyError({
foo: 'this is foo',
bar: true,
cause: TypeError('this is the cause'),
});
console.log(myError instanceof Error); // true
License
MIT © Julien Polo julien.polo@gmail.com
Index
Constructor
Other
Constructor
CustomError
Other
CustomError
A custom error type
Type parameters
- Properties: { name: string }
Return a new
CustomError
initial properties