mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
fix: handle special characters in IPC errors and skip translation
This commit is contained in:
parent
5227287410
commit
68f3b787d0
2 changed files with 20 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -304,6 +304,7 @@ export class AppComponent implements OnDestroy, AfterViewInit {
|
|||
this._snackService.open({
|
||||
msg: errMsg,
|
||||
type: 'ERROR',
|
||||
isSkipTranslate: true,
|
||||
});
|
||||
Log.err(data);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue