MCPcopy Create free account
hub / github.com/VirtualHotBar/NetMount / printError

Function printError

src/utils/rclone/request.ts:91–126  ·  view source on GitHub ↗

* 打印错误信息

(error: Error | Response)

Source from the content-addressed store, hash-verified

89 * 打印错误信息
90 */
91async function printError(error: Error | Response): Promise<void> {
92 console.error('Rclone API Error:', error)
93
94 let errorMessage = ''
95
96 if (error instanceof Response) {
97 if (error.status) {
98 errorMessage += `HTTP ${error.status} - ${error.statusText}\n`
99 }
100 try {
101 const text = await error.text()
102 if (text) {
103 try {
104 const errorData = JSON.parse(text) as { error?: unknown }
105 if (typeof errorData?.error === 'string' && errorData.error.trim()) {
106 errorMessage += `\n${errorData.error}`
107 } else {
108 errorMessage += `\n${JSON.stringify(errorData)}`
109 }
110 } catch {
111 errorMessage += `\n${text}`
112 }
113 }
114 } catch {
115 // 忽略 JSON 解析错误
116 }
117 } else if (error instanceof Error) {
118 errorMessage = error.message
119 } else {
120 errorMessage = String(error)
121 }
122
123 if (errorMessage) {
124 Message.error(errorMessage)
125 }
126}
127
128/**
129 * Rclone API Ping 检查

Callers 4

rclone_api_postFunction · 0.85
rclone_api_getFunction · 0.85
rclone_api_post_asyncFunction · 0.85
rclone_api_job_statusFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected