chore(routes): fix no-explicit-any lint/ts error for catch blocks

This commit is contained in:
Panagiotis Papadopoulos 2025-03-08 16:01:53 +01:00
parent 272d7cd652
commit e3d0c53d03
5 changed files with 11 additions and 8 deletions

View File

@ -33,8 +33,11 @@ async function exec(req: Request) {
executionResult: result, executionResult: result,
maxEntityChangeId: syncService.getMaxEntityChangeId() maxEntityChangeId: syncService.getMaxEntityChangeId()
}; };
} catch (e: any) { } catch (e: unknown) {
return { success: false, error: e.message }; return {
success: false,
error: (e instanceof Error) ? e.message : "Unknown Error"
};
} }
} }

View File

@ -56,10 +56,10 @@ function execute(req: Request) {
success: true, success: true,
results results
}; };
} catch (e: any) { } catch (e: unknown) {
return { return {
success: false, success: false,
error: e.message error: (e instanceof Error) ? e.message : "Unknown Error"
}; };
} }
} }

View File

@ -30,10 +30,10 @@ async function testSync() {
syncService.sync(); syncService.sync();
return { success: true, message: t("test_sync.successful") }; return { success: true, message: t("test_sync.successful") };
} catch (e: any) { } catch (e: unknown) {
return { return {
success: false, success: false,
message: e.message error: (e instanceof Error) ? e.message : "Unknown Error"
}; };
} }
} }

View File

@ -5,7 +5,7 @@ import express from "express";
import { isDev, isElectron } from "../services/utils.js"; import { isDev, isElectron } from "../services/utils.js";
import type serveStatic from "serve-static"; import type serveStatic from "serve-static";
const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<any, Record<string, any>>>) => { const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<unknown, Record<string, unknown>>>) => {
if (!isDev) { if (!isDev) {
options = { options = {
maxAge: "1y", maxAge: "1y",

View File

@ -477,7 +477,7 @@ function route(method: HttpMethod, path: string, middleware: express.Handler[],
if (result?.then) { if (result?.then) {
// promise // promise
result.then((promiseResult: unknown) => handleResponse(resultHandler, req, res, promiseResult, start)).catch((e: any) => handleException(e, method, path, res)); result.then((promiseResult: unknown) => handleResponse(resultHandler, req, res, promiseResult, start)).catch((e: unknown) => handleException(e, method, path, res));
} else { } else {
handleResponse(resultHandler, req, res, result, start); handleResponse(resultHandler, req, res, result, start);
} }