Endo API documentation - v0.2.0 / Exports / @endo/common / apply-labeling-error
Module: apply-labeling-error
Table of contents
Functions
Functions
applyLabelingError
▸ applyLabelingError<A, R>(func, args, label?): R
Calls func(...args), but annotating any failure error with label.
If label is omitted or undefined, then this is equivalent to `func(...args).
Otherwise, if it successfully returns a non-promise, that non-promise is returned.
If it throws, rethrow a similar error whose message is
`${label}: ${originalMessage}`That way, in an error happens deep within a stack of calls to applyLabelingError, the resulting error will show the stack of labels.
If it returns a promise, then applyLabelingError cannot tell until that promise settles whether it represents a success or failure. So it immediately returns a new promise. If the original promise fulfills, then the fulfillment is propagated to the returned promise.
If the promise rejects with an error, then the returned promise is rejected with a similar promise, prefixed with the label in that same way.
Type parameters
| Name |
|---|
A |
R |
Parameters
| Name | Type | Default value |
|---|---|---|
func | (...args: A[]) => R | undefined |
args | A[] | undefined |
label? | string | number | undefined |
Returns
R