Standard error
Library extending javascript error.
Usage:
Creating new standard error:
import BaseError from '@g2a/standard-error';
class ExampleError extends BaseError {
static defaultMessage = 'Example error';
}
throw new ExampleError();
throw new ExampleError('<NEW_MESSAGE>');
throw new ExampleError('<NEW_MESSAGE>', { code: '<ERROR_CODE>', foo: 'foo' });
throw new ExampleError({ code: '<ERROR_CODE>' });
Creating standard error based on normal error (or something else):
import BaseError from '@g2a/standard-error';
const error = new Error('<ERROR_MESSAGE>');
const yourError = BaseError.from(error);