exception-error
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

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)
}

/exception-error/

    Package Sidebar

    Install

    npm i exception-error

    Weekly Downloads

    1

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    5.15 kB

    Total Files

    8

    Last publish

    Collaborators

    • ~xinlei3166