If you want to print the error reason, you should catch it and format the `ZodError`
If you want to print the error reason, you should catch it and format the
ZodError
1ac93aea0842f2d3ef10111b5bf7bb11

const maxFutureDays = await step.do(`get ${key} max days`, async () => 330);while (somecondition){
await step.do(`some action `${somekey}`, async () => {});
} async tail(events, env, ctx) {
// Check if events array exists and has items
if (!Array.isArray(events) || events.length === 0) {
return new Response("No events found", { status: 200 });
}
// Only proceed if there's an exception AND exceptions array is not empty
const event = events[0];
if (event.outcome !== "exception" || !event.exceptions?.length) {
return new Response("No exception found", { status: 200 });
}
// Log the event structure to help us understand the data
console.log("Tail worker event:", JSON.stringify(events, null, 2));
... const payload = await step.do('prepares payload', async () => {
const isDev = this.env.ENVIRONMENT === 'dev';
const data = isDev ? mockData : event.payload;
console.log("Received payload:", JSON.stringify(data, null, 2));
throw new Error("Testing error handling with payload data");
return data;
});