ts-err
v1.0.0
Published
TypeScript Exceptions
Downloads
1
Readme
ts-err
Installation
npm i ts-err
Basic Errors
ApplicationError(message: string, context: any, previous: Error)
import { ApplicationError } from 'ts-error';
const a = 5;
throw new ApplicationError('Something happened!', {
value: a
});
Error chains
import { ApplicationError } from 'ts-error';
try {
throw new Error('Hello!');
}
catch(e) {
throw new ApplicationError('Greeting failed', null, e);
}
Http Errors (with Axios)
HttpError(message: string, error: any)
import { default as axios } from 'axios';
import { HttpError } from 'ts-err';
axios.get('https://google.com/teapot').catch(err => {
throw new HttpError('Could not fetch teapot', err);
})