You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Pre-migration tip:** Update v4 projects to track history using `actor.subscribe()`.
1020
1020
1021
+
### Actions can throw errors without `escalate`
1022
+
1023
+
:::breakingchange
1024
+
1025
+
Breaking change
1026
+
1027
+
:::
1028
+
1029
+
The `escalate` action creator is removed. In XState v5 actions can throw errors, and they will propagate as expected. Errors can be handled using an `onError` transition.
1030
+
1031
+
<Tabs>
1032
+
<TabItem value="v5" label="XState v5 beta">
1033
+
1034
+
```ts
1035
+
// ✅
1036
+
constchildMachine=createMachine({
1037
+
// This will be sent to the parent machine that invokes this child
1038
+
// highlight-start
1039
+
entry: () => {
1040
+
thrownewError('This is some error')
1041
+
}
1042
+
// highlight-end
1043
+
});
1044
+
1045
+
constparentMachine=createMachine({
1046
+
invoke: {
1047
+
src: childMachine,
1048
+
// highlight-start
1049
+
onError: {
1050
+
actions: ({ context, event }) => {
1051
+
console.log(event.data);
1052
+
// {
1053
+
// type: ...,
1054
+
// data: {
1055
+
// message: 'This is some error'
1056
+
// }
1057
+
// }
1058
+
}
1059
+
}
1060
+
// highlight-end
1061
+
}
1062
+
});
1063
+
```
1064
+
1065
+
</TabItem>
1066
+
1067
+
<TabItem value="v4" label="XState v4">
1068
+
1069
+
```ts
1070
+
// ❌ DEPRECATED
1071
+
constchildMachine=createMachine({
1072
+
// highlight-start
1073
+
entry: escalate('This is some error')
1074
+
// highlight-end
1075
+
});
1076
+
1077
+
/* ... */
1078
+
```
1079
+
1080
+
</TabItem>
1081
+
</Tabs>
1082
+
1021
1083
## Actors
1022
1084
1023
1085
### Use actor logic creators for `invoke.src` instead of functions
0 commit comments