From ec6b5b361c35d7ab6038f9198d4660276af4a212 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Thu, 14 Mar 2024 21:02:49 +0200 Subject: Better error reporting on failure --- src/index.ts | 12 ++++++++++++ src/instagram_task.ts | 1 + 2 files changed, 13 insertions(+) diff --git a/src/index.ts b/src/index.ts index 3a48757..329d7b6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -61,10 +61,21 @@ app.command("/veeti", async ({ command, ack, respond, client }) => { } }; + const respondTaskFailed = async (err: unknown) => { + console.error("Task failed", err); + void respond({ + text: + "Failed to download video, please try again later. Error: " + + String(err), + response_type: "ephemeral", + }); + }; + addTask({ type: "download_instagram", url, respondWithFile, + respondTaskFailed, }); }); @@ -83,6 +94,7 @@ const taskLoop = async () => { } }, MAX_RETRIES); } catch (e) { + void task.respondTaskFailed(e); console.error("Task failed after max retries, skipping task.", task, e); } } else { diff --git a/src/instagram_task.ts b/src/instagram_task.ts index 09b82b5..bea1e38 100644 --- a/src/instagram_task.ts +++ b/src/instagram_task.ts @@ -6,6 +6,7 @@ export interface InstagramTask { type: "download_instagram"; url: string; respondWithFile: (filePath: string) => Promise; + respondTaskFailed: (err: unknown) => Promise; } export const runDownloadInstagramTask = async (task: InstagramTask) => { -- cgit v1.3