优化 / 高 / 前端组件
src/components/common/ErrorBoundary.tsx
ErrorBoundary 捕获渲染错误后:
但未将错误上报到主进程:
class ErrorBoundary extends React.Component { componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { // 上报到主进程 window.metonaAPI?.reportError({ type: 'react_error_boundary', error: error.message, stack: error.stack, componentStack: errorInfo.componentStack, timestamp: Date.now(), }); // 同时 console.error 保留 console.error('ErrorBoundary caught:', error, errorInfo); } }
主进程添加 IPC:
ipcMain.handle('error:report', (event, payload) => { log.error('[Frontend Error]', payload); auditService.log({ type: 'frontend_error', payload }); });
可选集成 Sentry 等错误监控服务。
No dependencies set.
The note is not visible to the blocked user.
问题类型
优化 / 高 / 前端组件
文件位置
src/components/common/ErrorBoundary.tsx问题描述
ErrorBoundary 捕获渲染错误后:
但未将错误上报到主进程:
影响
建议修复
主进程添加 IPC:
可选集成 Sentry 等错误监控服务。