Error handling seems quite complex. I have a tail worker that should post to the bug tracking app, b

Error handling seems quite complex. I have a tail worker that should post to the bug tracking app, but it doesn't seem to catch exceptions at all tail worker excerpt:
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));

...
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));

...
workflow step
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;
});
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;
});
What am I missing? It never throws the error
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?