AwaitingPromiseError

AwaitingPromiseError

new AwaitingPromiseError()

An error that occurs while waiting for a Promise or asynchronous function
to resolve. Typically found in the catch() handler of a promise or the
try/catch handler of an await asyncFn() statement. In addition to an
error message that occurred during the asynchronous event, this error
can track other potentially pertinent information such as the promise
in question and/or an AsyncFunctionExecutionError wrapping the originally
thrown generic error.

Source:

Methods

⌾⠀asyncFn(error, fn, args, result, promise) → {AwaitingPromiseError}

A static helper method that creates an error but also takes and records
the additional data with regards to the associated async function call
that caused the error to occur. Optionally a promise can be assigned by
giving one as the last parameter.

Source:
Parameters:
Name Type Description
error Error | string

any error present at the time of failure

fn function

the function that failed

args Array.<mixed>

any arguments passed to the failed fn

result mixed

any result returned by the failed function

promise Promise.<mixed>

an associated promise, if available

Returns:
Type:
AwaitingPromiseError

a newly minted AwaitingPromiseError with
all the specified data

⌾⠀setPromise(promise) → {AwaitingPromiseError}

A promise that potentially spawned the error is something that this type
of Error tracks. You can set this inline with a return statement by using
this helper function.

i.e.

let promise; // define elsewhere
promise
  .then(result => ({}))
  .catch(error => {
    throw new AwaitingPromiseError(error).setPromise(promise)
  })
Source:
Parameters:
Name Type Description
promise Promise.<mixed>

the promise to store as a chained call

Returns:
Type:
AwaitingPromiseError

this for use in a chained function call