From 68f3b787d0fdeb693b78a00c8563030caae05698 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Fri, 21 Nov 2025 12:20:15 +0100 Subject: [PATCH] fix: handle special characters in IPC errors and skip translation --- .../error-handler-with-frontend-inform.ts | 20 ++++++++++++++++++- src/app/app.component.ts | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/electron/error-handler-with-frontend-inform.ts b/electron/error-handler-with-frontend-inform.ts index c1162b544..d6eaaff9f 100644 --- a/electron/error-handler-with-frontend-inform.ts +++ b/electron/error-handler-with-frontend-inform.ts @@ -47,7 +47,7 @@ function _handleError( if (_isReadyForFrontEndError()) { mainWin.webContents.send(IPC.ERROR, { error: e, - errorStr: e && String(e), + errorStr: _getErrorStr(e), stack, }); } else { @@ -55,3 +55,21 @@ function _handleError( throw errObj; } } + +// eslint-disable-next-line prefer-arrow/prefer-arrow-functions +function _getErrorStr(e: unknown): string { + if (typeof e === 'string') { + return e; + } + if (e instanceof Error) { + return e.toString(); + } + if (typeof e === 'object' && e !== null) { + try { + return JSON.stringify(e); + } catch (err) { + return String(e); + } + } + return String(e); +} diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 6b7462305..9acb42149 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -304,6 +304,7 @@ export class AppComponent implements OnDestroy, AfterViewInit { this._snackService.open({ msg: errMsg, type: 'ERROR', + isSkipTranslate: true, }); Log.err(data); });