1.0.1 • Published 6 years ago

catch-async v1.0.1

Weekly downloads
22
License
MIT
Repository
github
Last release
6 years ago

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

1.0.1

6 years ago

1.0.0

6 years ago