mirror of
https://github.com/zadam/trilium.git
synced 2025-11-12 16:25:51 +01:00
chore(share): use safeExtractMessageAndStackFromError to get rid of "any" in try/catch blocks
This commit is contained in:
@@ -2,6 +2,7 @@ import { beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import supertest from "supertest";
|
||||
import { initializeTranslations } from "../services/i18n.js";
|
||||
import type { Application, Request, Response, NextFunction } from "express";
|
||||
import { safeExtractMessageAndStackFromError } from "../services/utils.js";
|
||||
|
||||
let app: Application;
|
||||
|
||||
@@ -11,8 +12,9 @@ describe("Share API test", () => {
|
||||
beforeAll(async () => {
|
||||
initializeTranslations();
|
||||
app = (await import("../app.js")).default;
|
||||
app.use((err: any, req: Request, res: Response, next: NextFunction) => {
|
||||
if (err.message.includes("Cannot set headers after they are sent to the client")) {
|
||||
app.use((err: unknown, req: Request, res: Response, next: NextFunction) => {
|
||||
const [errMessage] = safeExtractMessageAndStackFromError(err)
|
||||
if (errMessage.includes("Cannot set headers after they are sent to the client")) {
|
||||
cannotSetHeadersCount++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user