File tree Expand file tree Collapse file tree 4 files changed +25
-9
lines changed Expand file tree Collapse file tree 4 files changed +25
-9
lines changed Original file line number Diff line number Diff line change
1
+ import { logErrorToFile } from '$lib/backend' ;
1
2
import { SilentError } from '$lib/error/error' ;
2
3
import { showError } from '$lib/notifications/toasts' ;
3
4
import { captureException } from '@sentry/sveltekit' ;
4
- import { error as logErrorToFile } from '@tauri-apps/plugin-log' ;
5
5
import type { HandleClientError } from '@sveltejs/kit' ;
6
6
7
7
// SvelteKit error handler.
@@ -61,13 +61,10 @@ function logError(error: unknown) {
61
61
showError ( 'Unhandled exception' , error ) ;
62
62
}
63
63
64
+ const logMessage = loggableError ( error ) ;
65
+ logErrorToFile ( logMessage ) ;
66
+
64
67
console . error ( error ) ;
65
- if ( import . meta. env . VITE_BUILD_TARGET === 'web' ) {
66
- // TODO: Replace with electron log file
67
- } else {
68
- const errorMessage = loggableError ( error ) ;
69
- logErrorToFile ( errorMessage ) ;
70
- }
71
68
} catch ( err : unknown ) {
72
69
console . error ( 'Error while trying to log error.' , err ) ;
73
70
}
Original file line number Diff line number Diff line change 1
- import Tauri , { tauriPathSeparator } from '$lib/backend/tauri' ;
2
- import Web , { webPathSeparator } from '$lib/backend/web' ;
1
+ import Tauri , { tauriLogErrorToFile , tauriPathSeparator } from '$lib/backend/tauri' ;
2
+ import Web , { webLogErrorToFile , webPathSeparator } from '$lib/backend/web' ;
3
3
import { InjectionToken } from '@gitbutler/shared/context' ;
4
4
import type { IBackend } from '$lib/backend/backend' ;
5
5
@@ -27,4 +27,13 @@ export function platformPathSeparator(): string {
27
27
return tauriPathSeparator ( ) ;
28
28
}
29
29
30
+ export function logErrorToFile ( error : string ) {
31
+ if ( import . meta. env . VITE_BUILD_TARGET === 'web' ) {
32
+ webLogErrorToFile ( error ) ;
33
+ return ;
34
+ }
35
+
36
+ tauriLogErrorToFile ( error ) ;
37
+ }
38
+
30
39
export * from '$lib/backend/backend' ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
11
11
} from '@tauri-apps/plugin-clipboard-manager' ;
12
12
import { open as filePickerTauri , type OpenDialogOptions } from '@tauri-apps/plugin-dialog' ;
13
13
import { readFile as tauriReadFile } from '@tauri-apps/plugin-fs' ;
14
+ import { error as logErrorToFile } from '@tauri-apps/plugin-log' ;
14
15
import { platform } from '@tauri-apps/plugin-os' ;
15
16
import { relaunch as relaunchTauri } from '@tauri-apps/plugin-process' ;
16
17
import { Store } from '@tauri-apps/plugin-store' ;
@@ -75,6 +76,10 @@ class TauriDiskStore implements DiskStore {
75
76
}
76
77
}
77
78
79
+ export async function tauriLogErrorToFile ( error : string ) {
80
+ await logErrorToFile ( error ) ;
81
+ }
82
+
78
83
export function tauriPathSeparator ( ) : string {
79
84
const platformName = platform ( ) ;
80
85
return platformName === 'windows' ? '\\' : '/' ;
Original file line number Diff line number Diff line change @@ -52,6 +52,11 @@ class WebDiskStore implements DiskStore {
52
52
}
53
53
}
54
54
55
+ export function webLogErrorToFile ( error : string ) {
56
+ // TODO: Implement this for the web version if needed
57
+ console . error ( 'Logging to file is not supported in web builds.' ) ;
58
+ console . error ( error ) ;
59
+ }
55
60
export function webPathSeparator ( ) : string {
56
61
return '/' ; // Web uses forward slashes for path
57
62
}
You can’t perform that action at this time.
0 commit comments