@@ -17,7 +17,7 @@ import { getGlobalBackendState } from '../main/globalBackendState';
17
17
import logger from '../main/logger' ;
18
18
import { getLoadedFilePath } from '../utils/getLoadedFile' ;
19
19
20
- async function reportListenerErrorInBackend (
20
+ async function showListenerErrorInMessageBox (
21
21
mainWindow : BrowserWindow ,
22
22
error : unknown ,
23
23
) : Promise < void > {
@@ -40,17 +40,18 @@ async function reportListenerErrorInBackend(
40
40
}
41
41
}
42
42
43
- function reportListenerErrorInFrontend ( _ : BrowserWindow , error : unknown ) : void {
43
+ function sendListenerErrorToFrontend ( _ : BrowserWindow , error : unknown ) : void {
44
+ // NOTE: these log messages are forwarded to the frontend
44
45
if ( error instanceof Error ) {
45
46
logger . error ( error . message ) ;
46
47
} else {
47
48
logger . error ( 'Unexpected internal error' ) ;
48
49
}
49
50
}
50
51
51
- export const ListenerErrorReporter = {
52
- Backend : reportListenerErrorInBackend ,
53
- Frontend : reportListenerErrorInFrontend ,
52
+ export const ListenerErrorReporting = {
53
+ ShowMessageBox : showListenerErrorInMessageBox ,
54
+ SendToFrontend : sendListenerErrorToFrontend ,
54
55
} ;
55
56
56
57
type FuncType < T > = T extends ( ...args : infer P ) => infer R
@@ -68,7 +69,7 @@ export function createVoidListenerCallbackWithErrorHandling<F>(
68
69
reportError : (
69
70
mainWindow : BrowserWindow ,
70
71
error : unknown ,
71
- ) => Promise < void > | void = reportListenerErrorInBackend ,
72
+ ) => Promise < void > | void = showListenerErrorInMessageBox ,
72
73
) : ( ...args : FTParameters < F > ) => Promise < void > {
73
74
return async ( ...args : FTParameters < F > ) : Promise < void > => {
74
75
try {
@@ -86,7 +87,7 @@ export function createListenerCallbackWithErrorHandling<F>(
86
87
reportError : (
87
88
mainWindow : BrowserWindow ,
88
89
error : unknown ,
89
- ) => Promise < void > | void = reportListenerErrorInBackend ,
90
+ ) => Promise < void > | void = showListenerErrorInMessageBox ,
90
91
) : ( ...args : FTParameters < F > ) => Promise < ReturnTypeWithoutPromise < F > > {
91
92
return async (
92
93
...args : FTParameters < F >
0 commit comments