diff --git a/pages/repo.ts b/pages/repo.ts index 7ae32b8..76913f2 100644 --- a/pages/repo.ts +++ b/pages/repo.ts @@ -13,7 +13,7 @@ async function fetchFile(file: string): Promise { return await client.getObject(config.minio.bucket, file); } catch(err: unknown) { console.log(`Fail to fetch ${file}`); - throw Error("Required resource doen't exist."); + throw URIError("Required resource doen't exist."); } } @@ -37,7 +37,10 @@ class Repo extends Page{ }); }); } catch(err: unknown) { - res.status(404).send(err as string); + if (err instanceof URIError) { + res.status(404).send(String(err)); + return; + } if (err instanceof Error) throw err; else throw Error(String(err)); }