catch-async

1.0.1 • Public • Published

Catch Async

Utility used to wrap root async functions to avoid uncaught promise errors to go silent.

catchAsync is intented for use in the root-level of an asyncronous chain of functions, basically avoiding the need of using try/catch and risking to leave silent errors in code.

API Documentation

Table of Contents

catchAsync

src/index.js:38-51

Returns an async function wrapped in a try catch function. It will by default log any error thrown in the async function unless a handleError function is provided. In that case it will instead call handleError

Parameters

  • asyncFunction Function
  • options Object? (optional, default {})
    • options.handleError Function? if this function is provided then catchAsync will call it instead of logging the error
    • options.logType String determines what logging method is used when an error is caught. Can be 'error', 'info', 'log' or 'warn' (optional, default 'error')

Returns Function Wrapped async function

Readme

Keywords

none

Package Sidebar

Install

npm i catch-async

Weekly Downloads

72

Version

1.0.1

License

MIT

Unpacked Size

7.63 kB

Total Files

14

Last publish

Collaborators

  • narzerus