more stuff to improve robustness
This commit is contained in:
@ -5,10 +5,30 @@ import './lib/dev-logger';
|
||||
// Tauri bridge polyfill: must be imported before App so window.electronAPI is available to all components
|
||||
import './lib/tauri-bridge';
|
||||
import App from './App';
|
||||
import ErrorBoundary from './components/ErrorBoundary';
|
||||
import './index.css';
|
||||
|
||||
window.addEventListener('error', (e) => {
|
||||
if (e.error) {
|
||||
try {
|
||||
console.error('[GlobalError]', e.error.message, e.error.stack);
|
||||
window.electronAPI?.logError?.(e.error.message, e.error.stack || '', '');
|
||||
} catch {}
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('unhandledrejection', (e) => {
|
||||
const reason = e.reason instanceof Error ? e.reason : new Error(String(e.reason));
|
||||
try {
|
||||
console.error('[UnhandledRejection]', reason.message, reason.stack);
|
||||
window.electronAPI?.logError?.(reason.message, reason.stack || '', '');
|
||||
} catch {}
|
||||
});
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
<ErrorBoundary>
|
||||
<App />
|
||||
</ErrorBoundary>
|
||||
</React.StrictMode>,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user