more stuff to improve robustness
This commit is contained in:
11
frontend/src/lib/assert.ts
Normal file
11
frontend/src/lib/assert.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export function assert(condition: boolean, message: string): asserts condition {
|
||||
if (!condition) {
|
||||
const error = new Error(`Assertion failed: ${message}`);
|
||||
if (import.meta.env.DEV) {
|
||||
console.error('[Assertion]', message, error.stack);
|
||||
throw error;
|
||||
} else {
|
||||
console.warn('[Assertion] (prod silenced):', message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,4 +120,20 @@ window.electronAPI = {
|
||||
deleteModel: (path: string): Promise<void> => {
|
||||
return invoke('delete_model', { path });
|
||||
},
|
||||
|
||||
logError: (message: string, stack: string, componentStack: string): Promise<void> => {
|
||||
return invoke('log_error', { message, stack, componentStack });
|
||||
},
|
||||
|
||||
writeAutosave: (data: string): Promise<void> => {
|
||||
return invoke('write_autosave', { data });
|
||||
},
|
||||
|
||||
readAutosave: (): Promise<string | null> => {
|
||||
return invoke('read_autosave');
|
||||
},
|
||||
|
||||
deleteAutosave: (): Promise<void> => {
|
||||
return invoke('delete_autosave');
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user