Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-catcher

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-catcher

An error catching wrapper for ES7 async/await functions in express

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by33.33%
Maintainers
1
Weekly downloads
 
Created
Source

async-catcher

async-catcher is an error catching wrapper for ES7 async/await functions in express.

Usage
    var catcher = require('async-catcher')
    
    app.get('/my/url', catcher(async function(req, res) {
        throw Error('Unhandled error');
    }));

In this scenario, the default handler will call Express's next() function and pass in the unhandled error.

You may also supply a handler:

    var catcher = require('async-catcher')
    
    app.get('/my/url', catcher(async function(req, res) {
        throw Error('Unhandled error');
    }, function(err, req, res){
        res.status(400).send('An error occurred');
    }));

NOTE

This module does not inherently add async support, but plays well with the transpiled implementations from Babel and Traceur.

Keywords

FAQs

Package last updated on 02 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc