1.20.0 - Async Error Payloads
Minor Release. Thanks to @ultd for bringing up the suggestion and working on these changes.
- Allow the passing of an
errorPayload
to the end result of an Async Action.
// response from inside an async action
return errorResult(["NOT_FOUND"], "User was not found", errorPayload)
This allows you to pass an additional object which you define, in order to communicate more information / data about what went wrong.
If an async action has finished resolving, and is in an error state (isFailure
represents this when making use of AsyncAction.use()
), then the error payload will be defined (if you have passed something in for it):
const getUserAction = GetUserAsyncAction.use({ userId: "asd" });
if (getUserAction.isFailure) {
getUserAction.errorPayload // <- Would be defined if you are making use of it
}