diff --git a/routes/api/export/gallery/zip/[gid].ts b/routes/api/export/gallery/zip/[gid].ts index 149162b..636cfb3 100644 --- a/routes/api/export/gallery/zip/[gid].ts +++ b/routes/api/export/gallery/zip/[gid].ts @@ -9,11 +9,6 @@ export const handler: Handlers = { return new Response("Bad Request", { status: 400 }); } const m = get_task_manager(); - try { - return get_export_zip_response(gid, m.db); - } catch (e) { - console.error(e); - return new Response("Gallery not found.", { status: 404 }); - } + return get_export_zip_response(gid, m.db); }, }; diff --git a/server/export_zip.ts b/server/export_zip.ts index e2291f0..0e34827 100644 --- a/server/export_zip.ts +++ b/server/export_zip.ts @@ -4,7 +4,7 @@ import { addZero } from "../utils.ts"; export function get_export_zip_response(gid: number, db: EhDb) { const gmeta = db.get_gmeta_by_gid(gid); - if (!gmeta) throw Error("Gallery not found."); + if (!gmeta) return new Response("Gallery not found.", { status: 404 }); const pmetas = db.get_pmeta(gid).sort((a, b) => a.index - b.index); const p = pmetas.length; const l = gmeta.filecount.toString().length; diff --git a/task_manager.ts b/task_manager.ts index 9297735..b2ae239 100644 --- a/task_manager.ts +++ b/task_manager.ts @@ -48,10 +48,10 @@ export class TaskManager extends EventTarget { // @ts-ignore Checked type addEventListener( type: T, - callback: ((e: EventMap[T]) => void | Promise) | null, + callback: (e: EventMap[T]) => void | Promise, options?: boolean | AddEventListenerOptions, ): void { - super.addEventListener(type, callback, options); + super.addEventListener(type, callback, options); } get aborted() { return this.#abort.signal.aborted; @@ -147,12 +147,12 @@ export class TaskManager extends EventTarget { // @ts-ignore Checked type removeEventListener( type: T, - callback: ((e: EventMap[T]) => void | Promise) | null, + callback: (e: EventMap[T]) => void | Promise, options?: boolean | EventListenerOptions, ): void { super.removeEventListener( type, - callback, + callback, options, ); }