From 07fd5327b1180f7729fd0b8b843b96388fbbd734 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sat, 8 Mar 2025 00:22:12 +0100 Subject: [PATCH] refactor(routes/custom): get rid of "any" type catch blocks --- src/routes/custom.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/routes/custom.ts b/src/routes/custom.ts index d8b90de5c..40188bcc1 100644 --- a/src/routes/custom.ts +++ b/src/routes/custom.ts @@ -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);