Skip to content

1.20.0 - Async Error Payloads

Compare
Choose a tag to compare
@lostpebble lostpebble released this 30 Oct 12:08
· 43 commits to master since this release

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
}