From 40f79ee8161f883919cd030a04e34b411ef668c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 24 Nov 2024 12:43:28 +0800 Subject: [PATCH] fix: error handle --- src/onebot/action/OneBotAction.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/onebot/action/OneBotAction.ts b/src/onebot/action/OneBotAction.ts index ae5c8e7b..967d186a 100644 --- a/src/onebot/action/OneBotAction.ts +++ b/src/onebot/action/OneBotAction.ts @@ -1,7 +1,6 @@ import { ActionName, BaseCheckResult } from './router'; import Ajv, { ErrorObject, ValidateFunction } from 'ajv'; import { NapCatCore } from '@/core'; -import { isNull } from '@/common/helper'; import { NapCatOneBot11Adapter, OB11Return } from '@/onebot'; export class OB11Response { @@ -66,7 +65,7 @@ export abstract class OneBotAction { return OB11Response.ok(resData); } catch (e: any) { this.core.context.logger.logError('发生错误', e); - return OB11Response.error(e?.toString() || e?.stack?.toString() || '未知错误,可能操作超时', 200); + return OB11Response.error((e as Error).message.toString() || e?.stack?.toString() || '未知错误,可能操作超时', 200); } } @@ -80,7 +79,7 @@ export abstract class OneBotAction { return OB11Response.ok(resData, echo); } catch (e: any) { this.core.context.logger.logError('发生错误', e); - return OB11Response.error(e.toString() || e.stack?.toString(), 1200, echo); + return OB11Response.error((e as Error).message.toString() || e.stack?.toString(), 1200, echo); } }