BaseErrorFactory
BaseErrorFactory is factory for errors, that all other error factories inherit from. It provides error class registration and global error context.
Defines a new error class on ErrorFactory
class MyErrorFactory extends BaseErrorFactory { MyError = this.defineErrorClass( class MyError extends this.BaseError {} ); }
const factory = new MyErrorFactory();
throw new factory.MyError('some_error_code');
Creates new error factory with global error context that is avalible on all errors defined on returned error factory.
const contextualErrorFactory = new MyErrorFactory().withContext({ userId: '123-123' });
const error = new contextualErrorFactory.MyError('some_error_code');
error.context; // {userId: '123-123'}
Generated using TypeDoc
BaseErrorFactory
BaseErrorFactory is factory for errors, that all other error factories inherit from. It provides error class registration and global error context.