Skip to content

Commit 6e2d402

Browse files
authored
Merge pull request #820 from neuroglia-io/main
Refactor error handling
2 parents ca10bc3 + 0073684 commit 6e2d402

File tree

8 files changed

+1161
-528
lines changed

8 files changed

+1161
-528
lines changed

examples/new-patient-onboarding.json

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,21 @@
1616
{
1717
"name": "store-patient",
1818
"functionRef": "store-patient",
19-
"retryRef": "services-not-available-retry-strategy",
20-
"retryableErrors": [
21-
"service-not-available"
22-
]
19+
"onErrors": "fault-tolerance"
2320
},
2421
{
2522
"name": "assign-doctor",
2623
"functionRef": "assign-doctor",
27-
"retryRef": "services-not-available-retry-strategy",
28-
"retryableErrors": [
29-
"service-not-available"
30-
]
24+
"onErrors": "fault-tolerance"
3125
},
3226
{
3327
"name": "schedule-appt",
3428
"functionRef": "schedule-appt",
35-
"retryRef": "services-not-available-retry-strategy",
36-
"retryableErrors": [
37-
"service-not-available"
38-
]
29+
"onErrors": "fault-tolerance"
3930
}
4031
]
4132
}
4233
],
43-
"onErrors": [
44-
{
45-
"errorRef": "service-not-available",
46-
"end": true
47-
}
48-
],
4934
"end": true
5035
}
5136
],
@@ -70,12 +55,29 @@
7055
"operation": "api/services.json#scheduleAppointment"
7156
}
7257
],
73-
"errors": [
74-
{
75-
"name": "service-not-available",
76-
"code": "503"
77-
}
78-
],
58+
"errors": {
59+
"handlers":[
60+
{
61+
"name": "handle-503-errors",
62+
"when":[
63+
{
64+
"status": 503
65+
}
66+
],
67+
"retry": "services-not-available-retry-strategy"
68+
}
69+
],
70+
"policies":[
71+
{
72+
"name": "fault-tolerance",
73+
"handlers":[
74+
{
75+
"refName": "handle-503-errors"
76+
}
77+
]
78+
}
79+
]
80+
},
7981
"retries": [
8082
{
8183
"name": "services-not-available-retry-strategy",

examples/process-transactions.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"description": "Customer Banking Transactions Workflow",
44
"version": "1.0.0",
55
"specVersion": "0.8",
6-
"autoRetries": true,
76
"constants": {
87
"largetxamount": 5000
98
},

examples/provision-orders.json

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,6 @@
1010
"operation": "http://myapis.org/provisioningapi.json#doProvision"
1111
}
1212
],
13-
"errors": [
14-
{
15-
"name": "missing-order-id"
16-
},
17-
{
18-
"name": "missing-order-item"
19-
},
20-
{
21-
"name": "missing-order-quantity"
22-
}
23-
],
2413
"states": [
2514
{
2615
"name": "provision-order",
@@ -43,16 +32,34 @@
4332
"transition": "apply-order",
4433
"onErrors": [
4534
{
46-
"errorRef": "missing-order-id",
47-
"transition": "missing-id"
35+
"when": [
36+
{
37+
"type": "/samples/errors/missing-order-id"
38+
}
39+
],
40+
"then": {
41+
"transition": "missing-id"
42+
}
4843
},
4944
{
50-
"errorRef": "missing-order-item",
51-
"transition": "missing-item"
45+
"when": [
46+
{
47+
"type": "/samples/errors/missing-order-item"
48+
}
49+
],
50+
"then": {
51+
"transition": "missing-item"
52+
}
5253
},
5354
{
54-
"errorRef": "missing-order-quantity",
55-
"transition": "missing-quantity"
55+
"when": [
56+
{
57+
"type": "/samples/errors/missing-order-quantity"
58+
}
59+
],
60+
"then": {
61+
"transition": "missing-quantity"
62+
}
5663
}
5764
]
5865
},

package-lock.json

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

roadmap/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ _Status description:_
3737
| ✔️| Add the new `WORKFLOW` reserved keyword to workflow expressions |
3838
| ✔️| Update `ForEach` state iteration parameter example. This parameter is an expression variable, not a JSON property |
3939
| ✔️| Add the new `rest` function type [spec doc](https://github.com/serverlessworkflow/specification/tree/main/specification.md#using-functions-for-restful-service-invocations) |
40+
| ✔️| Refactor error handling and retries |
4041
| ✏️️| Add inline state defs in branches | |
4142
| ✏️️| Add "completedBy" functionality | |
4243
| ✏️️| Define workflow context | |

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy