MCPcopy Create free account
hub / github.com/xerrors/Yuxi / handleError

Method handleError

web/src/utils/errorHandler.js:13–45  ·  view source on GitHub ↗

* 处理通用错误 * @param {Error} error - 错误对象 * @param {string} context - 错误上下文 * @param {Object} options - 配置选项

(error, context = '操作', options = {})

Source from the content-addressed store, hash-verified

11 * @param {Object} options - 配置选项
12 */
13 static handleError(error, context = '操作', options = {}) {
14 const {
15 showMessage = true,
16 logToConsole = true,
17 customMessage = null,
18 severity = 'error'
19 } = options
20
21 // 控制台日志
22 if (logToConsole) {
23 console.error(`${context}失败:`, error)
24 }
25
26 // 用户提示
27 if (showMessage) {
28 const displayMessage = customMessage || this.getErrorMessage(error, context)
29
30 switch (severity) {
31 case 'warning':
32 message.warning(displayMessage)
33 break
34 case 'info':
35 message.info(displayMessage)
36 break
37 case 'error':
38 default:
39 message.error(displayMessage)
40 break
41 }
42 }
43
44 return error
45 }
46
47 /**
48 * 获取错误消息

Callers 5

handleNetworkErrorMethod · 0.95
handleChatErrorMethod · 0.95
handleValidationErrorMethod · 0.95
handleAsyncMethod · 0.95
createHandlerMethod · 0.95

Calls 1

getErrorMessageMethod · 0.95

Tested by

no test coverage detected