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
## Handling errors and deciding the retry behavior
169
+
## Advanced error handling and retrying
170
+
171
+
We provide a `handleError` callback on the task and in your `trigger.config` file. This gets called when an uncaught error is thrown in your task.
172
+
173
+
You can
174
+
175
+
- Inspect the error, log it, and return a different error if you'd like.
176
+
- Modify the retrying behavior based on the error, payload, context, etc.
177
+
178
+
If you don't return anything from the function it will use the settings on the task (or inherited from the config). So you only need to use this to override things.
179
+
180
+
### OpenAI error handling example
181
+
182
+
OpenAI calls can fail for a lot of reasons and the ideal retry behavior is different for each.
183
+
184
+
In this complicated example:
185
+
186
+
- We skip retrying if there's no Response status.
187
+
- We skip retrying if you've run out of credits.
188
+
- If there are no Response headers we let the normal retrying logic handle it (return undefined).
189
+
- If we've run out of requests or tokens we retry at the time specified in the headers.
0 commit comments