From 90be9b28a8ee7beda57e198bef06cccceae60182 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 4 Aug 2024 12:35:42 +0300 Subject: [PATCH] client-ts: Fix type error in server.ts --- src/public/app/services/server.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/public/app/services/server.ts b/src/public/app/services/server.ts index bfa5fc993..88e3c0bfd 100644 --- a/src/public/app/services/server.ts +++ b/src/public/app/services/server.ts @@ -238,8 +238,10 @@ async function reportError(method: string, url: string, statusCode: number, resp const toastService = (await import("./toast.js")).default; + const messageStr = (typeof message === "string" ? message : JSON.stringify(message)); + if ([400, 404].includes(statusCode) && response && typeof response === 'object') { - toastService.showError(message); + toastService.showError(messageStr); throw new ValidationError({ requestUrl: url, method, @@ -248,7 +250,7 @@ async function reportError(method: string, url: string, statusCode: number, resp }); } else { const title = `${statusCode} ${method} ${url}`; - toastService.showErrorTitleAndMessage(title, message); + toastService.showErrorTitleAndMessage(title, messageStr); toastService.throwError(`${title} - ${message}`); } }