refactor(routes/custom): get rid of "any" type catch blocks

This commit is contained in:
Panagiotis Papadopoulos 2025-03-08 00:22:12 +01:00
parent 4b6972fb21
commit 07fd5327b1

View File

@ -25,8 +25,9 @@ function handleRequest(req: Request, res: Response) {
try {
match = path.match(regex);
} catch (e: any) {
log.error(`Testing path for label '${attr.attributeId}', regex '${attr.value}' failed with error: ${e.message}, stack: ${e.stack}`);
} catch (e: unknown) {
const [errMessage, errStack] = e instanceof Error ? [e.message, e.stack] : ["Unknown Error", undefined];
log.error(`Testing path for label '${attr.attributeId}', regex '${attr.value}' failed with error: ${errMessage}, stack: ${errStack}`);
continue;
}
@ -45,10 +46,12 @@ function handleRequest(req: Request, res: Response) {
req,
res
});
} catch (e: any) {
log.error(`Custom handler '${note.noteId}' failed with: ${e.message}, ${e.stack}`);
} catch (e: unknown) {
const [errMessage, errStack] = e instanceof Error ? [e.message, e.stack] : ["Unknown Error", undefined];
res.setHeader("Content-Type", "text/plain").status(500).send(e.message);
log.error(`Custom handler '${note.noteId}' failed with: ${errMessage}, ${errStack}`);
res.setHeader("Content-Type", "text/plain").status(500).send(errMessage);
}
} else if (attr.name === "customResourceProvider") {
fileService.downloadNoteInt(attr.noteId, res);