Some checks failed
Build and Deploy Log Center / build-and-deploy (push) Failing after 1m19s
- 新增 app/self_report.py:后端运行时异常直接写入自身数据库 - main.py:添加全局异常处理器 + 启动时注册 log_center_api/web 项目 - web/api.ts:添加 reportError 函数 + Axios 5xx 拦截器 - web/main.tsx:添加 window.onerror / onunhandledrejection 全局捕获 - deploy.yaml:CI/CD 流水线各步骤失败时上报(build/deploy) - 重写 integration_guide.md:按三类上报(runtime/cicd/deployment)重新组织 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
27 lines
724 B
TypeScript
27 lines
724 B
TypeScript
import { StrictMode } from 'react'
|
||
import { createRoot } from 'react-dom/client'
|
||
import './index.css'
|
||
import App from './App.tsx'
|
||
import { reportError } from './api'
|
||
|
||
// 全局错误捕获:JS 运行时异常
|
||
window.onerror = (_message, source, lineno, colno, error) => {
|
||
if (error) {
|
||
reportError(error, { source, lineno, colno })
|
||
}
|
||
}
|
||
|
||
// 全局错误捕获:未处理的 Promise rejection
|
||
window.onunhandledrejection = (event: PromiseRejectionEvent) => {
|
||
const error = event.reason instanceof Error
|
||
? event.reason
|
||
: new Error(String(event.reason))
|
||
reportError(error, { type: 'unhandledrejection' })
|
||
}
|
||
|
||
createRoot(document.getElementById('root')!).render(
|
||
<StrictMode>
|
||
<App />
|
||
</StrictMode>,
|
||
)
|