summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2024-03-14 21:02:49 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2024-03-14 21:02:49 +0200
commitec6b5b361c35d7ab6038f9198d4660276af4a212 (patch)
tree64f72ef77e3fe3a1ab4e794049e77ebce5f102c5 /src
parent0057931a0e009cf40c0b1bb651d60432347e0dc7 (diff)
Better error reporting on failure
Diffstat (limited to 'src')
-rw-r--r--src/index.ts12
-rw-r--r--src/instagram_task.ts1
2 files changed, 13 insertions, 0 deletions
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<void>;
+ respondTaskFailed: (err: unknown) => Promise<void>;
}
export const runDownloadInstagramTask = async (task: InstagramTask) => {