Fix: crash when invalid uri is requested
All checks were successful
release-tag / release-image (push) Successful in 1m50s

This commit is contained in:
2024-10-15 04:09:19 +00:00
parent 44a0227ab1
commit 42255ef76f

View File

@@ -13,7 +13,7 @@ async function fetchFile(file: string): Promise<Readable> {
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));
}