mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 10:22:29 +08:00
refactor(routes/custom): get rid of "any" type catch blocks
This commit is contained in:
parent
4b6972fb21
commit
07fd5327b1
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user