/safe-await

Safely use async await without all the try/catch blocks

Primary LanguageJavaScript

Safe Await

Safely use async/await without all the try catch blocks

Usage

const safeAwait = require('safe-await')

async function fooBar() {
  const [error, data] = await safeAwait(promiseOne())

  if (error) {
    // handle error, retry, ignore, whatever
  }

  console.log(data)
}

See usage and tests for more examples.

Research

Other libraries