Browse Source

🐞 fix: 增加错误信息的输出

Pchen. 1 month ago
parent
commit
83c0b0a284
1 changed files with 12 additions and 11 deletions
  1. 12 11
      lib/Lepao/Mcp.js

+ 12 - 11
lib/Lepao/Mcp.js

@@ -74,7 +74,7 @@ class Mcp {
                 return '系统出错,请稍后再试'
                 return '系统出错,请稍后再试'
             return `绑定成功,姓名:${rows[0].name ?? '未更新,请使用乐跑登录器更新账号信息'},学号:${rows[0].student_num}`
             return `绑定成功,姓名:${rows[0].name ?? '未更新,请使用乐跑登录器更新账号信息'},学号:${rows[0].student_num}`
         } catch (error) {
         } catch (error) {
-            this.logger.error(`MCP绑定账号出错:${error.message}`)
+            this.logger.error(`MCP绑定账号出错:${error.stack}`)
             return '系统出错,请稍后再试'
             return '系统出错,请稍后再试'
         }
         }
     }
     }
@@ -137,7 +137,7 @@ class Mcp {
 
 
             return returnMsg
             return returnMsg
         } catch (error) {
         } catch (error) {
-            this.logger.error(`MCP查询账号信息出错:${error.message}`)
+            this.logger.error(`MCP查询账号信息出错:${error.stack}`)
             return '系统出错,请稍后再试'
             return '系统出错,请稍后再试'
         }
         }
     }
     }
@@ -156,7 +156,7 @@ class Mcp {
                 return '系统出错,请稍后再试'
                 return '系统出错,请稍后再试'
             return `解绑成功`
             return `解绑成功`
         } catch (error) {
         } catch (error) {
-            this.logger.error(`MCP解绑账号出错:${error.message}`)
+            this.logger.error(`MCP解绑账号出错:${error.stack}`)
             return '系统出错,请稍后再试'
             return '系统出错,请稍后再试'
         }
         }
     }
     }
@@ -193,7 +193,7 @@ class Mcp {
                 return '系统出错,请稍后再试'
                 return '系统出错,请稍后再试'
             return `更换成功`
             return `更换成功`
         } catch (error) {
         } catch (error) {
-            this.logger.error(`MCP更换邮箱出错:${error.message}`)
+            this.logger.error(`MCP更换邮箱出错:${error.stack}`)
             return '系统出错,请稍后再试'
             return '系统出错,请稍后再试'
         }
         }
     }
     }
@@ -242,7 +242,7 @@ class Mcp {
                 return '系统出错,请稍后再试'
                 return '系统出错,请稍后再试'
             return `操作成功`
             return `操作成功`
         } catch (error) {
         } catch (error) {
-            this.logger.error(`MCP更换通知方式出错:${error.message}`)
+            this.logger.error(`MCP更换通知方式出错:${error.stack}`)
             return '系统出错,请稍后再试'
             return '系统出错,请稍后再试'
         }
         }
     }
     }
@@ -296,9 +296,9 @@ class Mcp {
 
 
             return `操作成功,现在自动乐跑时间为:${data.auto_day.slice().sort((a, b) => {
             return `操作成功,现在自动乐跑时间为:${data.auto_day.slice().sort((a, b) => {
                 if (a === 0) return 1; if (b === 0) return -1; return a - b;
                 if (a === 0) return 1; if (b === 0) return -1; return a - b;
-            }).map(day => this.auto_day.find(item => item.value === day)?.label).join(',')} ${this.autoTimeLabel(data).replace(/今日/g, '')}`
+            }).map(day => this.auto_day.find(item => item.value === day)?.label).join(',')} ${auto_time === -1 ? '随机分配时段' : `${auto_time}~${auto_time + 1}时`}`
         } catch (error) {
         } catch (error) {
-            this.logger.error(`MCP更换设置自动乐跑时间出错:${error.message}`)
+            this.logger.error(`MCP更换设置自动乐跑时间出错:${error.stack}`)
             return '系统出错,请稍后再试'
             return '系统出错,请稍后再试'
         }
         }
     }
     }
@@ -346,15 +346,16 @@ class Mcp {
             if (!insertRows || insertRows.affectedRows === 0)
             if (!insertRows || insertRows.affectedRows === 0)
                 return '系统出错,请稍后再试'
                 return '系统出错,请稍后再试'
 
 
+            const auto_time = rows[0].auto_time
             const data = {
             const data = {
-                auto_time: rows[0].auto_time, auto_day
+                auto_time, auto_day
             }
             }
 
 
             return `操作成功,现在自动乐跑时间为:${data.auto_day.slice().sort((a, b) => {
             return `操作成功,现在自动乐跑时间为:${data.auto_day.slice().sort((a, b) => {
                 if (a === 0) return 1; if (b === 0) return -1; return a - b;
                 if (a === 0) return 1; if (b === 0) return -1; return a - b;
-            }).map(day => this.auto_day.find(item => item.value === day)?.label).join(',')} ${this.autoTimeLabel(data).replace(/今日/g, '')}`
+            }).map(day => this.auto_day.find(item => item.value === day)?.label).join(',')} ${auto_time === -1 ? '随机分配时段' : `${auto_time}~${auto_time + 1}时`}`
         } catch (error) {
         } catch (error) {
-            this.logger.error(`MCP更换设置自动乐跑时间出错:${error.message}`)
+            this.logger.error(`MCP更换设置自动乐跑时间出错:${error.stack}`)
             return '系统出错,请稍后再试'
             return '系统出错,请稍后再试'
         }
         }
     }
     }
@@ -429,7 +430,7 @@ class Mcp {
 
 
             return `提交成功`
             return `提交成功`
         } catch (error) {
         } catch (error) {
-            this.logger.error(`MCP工单创建出错:${error.message}`)
+            this.logger.error(`MCP工单创建出错:${error.stack}`)
             return '系统出错,请稍后再试'
             return '系统出错,请稍后再试'
         }
         }
     }
     }