fix: handle special characters in IPC errors and skip translation

This commit is contained in:
Johannes Millan 2025-11-21 12:20:15 +01:00
parent 5227287410
commit 68f3b787d0
2 changed files with 20 additions and 1 deletions

View file

@ -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);
}

View file

@ -304,6 +304,7 @@ export class AppComponent implements OnDestroy, AfterViewInit {
this._snackService.open({
msg: errMsg,
type: 'ERROR',
isSkipTranslate: true,
});
Log.err(data);
});