exception-error
v1.0.4
Published
exception-error
Downloads
7
Readme
exception-error
A small error handling library like python exception handling that supports extensions.
Install
npm install exception-error
yarn add exception-error
Quick Start
catch error
import { error, ExceptionError } from './index'
try {
throw error({ code: 'InvalidError', msg: 'invalid error' })
} catch (e) {
console.log(e.code)
}
try {
throw error('error')
} catch (e) {
console.log(e.msg)
}
try {
throw error('error')
} catch (e) {
console.log('e instanceof ExceptionError: ', e instanceof ExceptionError)
}