Skip to content

Spawning Promises. Error handling issue. #1779

Answered by davidkpiano
Sheldonfrith asked this question in Q&A
Discussion options

You must be logged in to vote

To handle errors for any spawned/invoked actor, you can use the error() function to create an "error.platform.[name]" string:

import { error } from 'xstate/lib/actions';


// ...
[error("firstPromise")]: {
  actions: (context, event) => {
    console.log("promise error data:", event.data);
  }
},

This is likely to be improved in v5.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Sheldonfrith
Comment options

Answer selected by Sheldonfrith
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants