0.0.0 • Published 6 years ago

no-unhandledrejection v0.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

no-unhandledrejection Build Status npm package

Simple lightweight (379B gzip size) processing unhandledRejection error library prevents unhandledRejection from causing program crashes. The usage scenario is that not all async functions need to be try catch.

Install

$ npm i no-unhandledrejection -S

Usage

// Browser
import noUnhandledRejection from 'no-unhandledrejection'
noUnhandledRejection()

// Node
require('no-unhandledrejection')()

// With Sentry
require('no-unhandledrejection')({
  callback (e) {
    Raven.captureException(e)
  }
})

Options

onlyProduction

Type: Boolean Default: false

Enable this plugin only under the production mode (process.env.NODE_ENV === 'production').

callback

Type: Function Default: noop

A generic callback function that handles unhandledRejection. Usually used for reporting such as Error Tracking or global error notification.

License

Copyright (c) 2017-present, Army-U. Released under the MIT License.