has there been any discussion on setting error callbacks for workflow steps? I’d love an `onError` c

has there been any discussion on setting error callbacks for workflow steps? I’d love an onError callback i could pass where i could set some custom logic to try when a step errors. E.g.:

export class TextGenerator extends WorkflowEntrypoint<CloudflareBindings> {
  async run(
    event: Readonly<WorkflowEvent<{ prompt: string }>>,
    step: WorkflowStep,
  ) {
    const { prompt } = event.payload;

    return await step.do(
      "generate-text",
      {
        retries: { limit: 3, delay: 1000, backoff: "exponential" },
        onError: async (error, retry) => {
          if (error instanceof AITimeoutError) {
            // Complex model timed out, try with a faster one first
            try {
              return await generateText({
                model: "gpt-3.5-turbo",
                prompt,
                timeout: 5000,
              });
            } catch {
              // If faster model fails, retry with original complex model (retry is the original callback in step.do)
              return retry();
            }
          }
          throw error;
        }
      },
Was this page helpful?