chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -68,18 +68,18 @@ const handleCertainError: (error: Error) => void = error => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 上报到自定义错误
|
||||
// Report a custom error
|
||||
if (errorName === 'CustomError') {
|
||||
const { eventName, msg } = error as CustomError;
|
||||
// 补充统一上报custom error event_name 用于监控
|
||||
// Supplement unified reporting custom error event_name for monitoring
|
||||
loggerWithScope.persist.error({
|
||||
eventName: ReportEventNames.CustomErrorReport,
|
||||
message: msg,
|
||||
error,
|
||||
meta: {
|
||||
name: error.name,
|
||||
originEventName: eventName, // 原始originEventName
|
||||
originErrorMessage: msg, // 原始 error msg
|
||||
originEventName: eventName, // originEventName
|
||||
originErrorMessage: msg, // Original error msg
|
||||
},
|
||||
});
|
||||
loggerWithScope.persist.error({
|
||||
@@ -93,12 +93,12 @@ const handleCertainError: (error: Error) => void = error => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 滤除已经上报到自定义事件
|
||||
// Filter out custom events that have been reported
|
||||
if (errorName === 'ApiError' || errorName === 'AxiosError') {
|
||||
return;
|
||||
}
|
||||
|
||||
// ChunkLoad 失败, 不上报,在slardar 静态资源异常统计
|
||||
// ChunkLoad failed, not reported, static resource exception statistics in slardar
|
||||
if (errorName === 'ChunkLoadError') {
|
||||
reporter.info({
|
||||
message: 'chunkLoadError',
|
||||
@@ -112,7 +112,7 @@ const handleCertainError: (error: Error) => void = error => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 不继承 Error 的错误,目前 case(semi 表单校验 )
|
||||
// Error that does not inherit Error, current case (semi form validation)
|
||||
if (errorName === 'notInstanceError') {
|
||||
let errorInfo;
|
||||
try {
|
||||
|
||||
@@ -16,23 +16,23 @@
|
||||
|
||||
export enum ReportEventNames {
|
||||
/**
|
||||
* 通用异常错误
|
||||
* generic exception error
|
||||
*/
|
||||
ChunkLoadError = 'chunk_load_error', // webpack chunk load 失败
|
||||
Unhandledrejection = 'unhandledrejection', // 异步错误兜底
|
||||
GlobalErrorBoundary = 'global_error_boundary', // 全局的errorBoundary 错误
|
||||
ChunkLoadError = 'chunk_load_error', // Webpack chunk load failed
|
||||
Unhandledrejection = 'unhandledrejection', // Asynchronous Error Bottom Line
|
||||
GlobalErrorBoundary = 'global_error_boundary', // Global errorBoundary error
|
||||
NotInstanceError = 'notInstanceError',
|
||||
CustomErrorReport = 'custom_error_report', // 统一上报的custom error
|
||||
CustomErrorReport = 'custom_error_report', // Uniformly reported customs errors
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已经明确的错误
|
||||
* Get the error that has been identified
|
||||
*
|
||||
* 1、CustomError: 业务方 throw new CustomError(ReportEventNames.xxx, 'xxx')
|
||||
* 2、AxiosError: 状态码非 2xx;
|
||||
* 3、ApiError: 状态码 2xx & 业务code !== 0
|
||||
* 4、ChunkLoadError: webpack chunk load 失败
|
||||
* 5、notInstanceError,不继承 Error 的错误,目前 case(semi 表单校验 )
|
||||
* 1. CustomError: The business party throws new CustomError (ReportEventNames.xxx, 'xxx')
|
||||
* 2. AxiosError: The status code is not 2xx;
|
||||
* 3, ApiError: status code 2xx & business code! == 0
|
||||
* 4. ChunkLoadError: webpack chunk load failed
|
||||
* 5. notInstanceError, error that does not inherit Error, the current case (semi form verification)
|
||||
*/
|
||||
export type CertainErrorName =
|
||||
| 'CustomError'
|
||||
|
||||
@@ -30,7 +30,7 @@ export class CustomError extends Error {
|
||||
this.ext = ext;
|
||||
}
|
||||
}
|
||||
// sladar beforeSend捕获到的错误需要通过.name判断错误类型
|
||||
// sladar beforeSend The captured error needs to determine the error type by .name.
|
||||
export const isCustomError = (error: unknown): error is CustomError =>
|
||||
error instanceof CustomError ||
|
||||
(error as CustomError)?.name === 'CustomError';
|
||||
|
||||
@@ -61,7 +61,7 @@ export const useErrorCatch = (slardarInstance: SlardarInstance) => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
// 3. 拦截 slardar 上报
|
||||
// 3. Interception of slardar reports
|
||||
useEffect(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const beforeSlardarSend = (e: any) => {
|
||||
|
||||
@@ -31,7 +31,7 @@ const loggerWithScope = logger.createLoggerWith({
|
||||
export const useRouteErrorCatch = (error: unknown) => {
|
||||
useEffect(() => {
|
||||
if (error) {
|
||||
// 处理不是error实例的情况
|
||||
// Handling cases that are not instances of error
|
||||
const realError =
|
||||
error instanceof Error
|
||||
? error
|
||||
@@ -39,7 +39,7 @@ export const useRouteErrorCatch = (error: unknown) => {
|
||||
ReportEventNames.GlobalErrorBoundary,
|
||||
`global error route catch error infos:${String(error)}`,
|
||||
);
|
||||
// 过滤 其他error
|
||||
// Filtering, other errors
|
||||
sendCertainError(realError, () => {
|
||||
loggerWithScope.persist.error({
|
||||
eventName: ReportEventNames.GlobalErrorBoundary,
|
||||
|
||||
Reference in New Issue
Block a user