Skip to content

Commit

Permalink
fix: When the bot is abnormal, it returns a prompt message instead of…
Browse files Browse the repository at this point in the history
… an exception message.
  • Loading branch information
lcjqyml committed May 8, 2023
1 parent d70d894 commit cc9eaa5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/chatbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export class ChatBot {

weChatBot: Wechaty;

errorResponse = "机器人异常,请稍后再试或联系管理员!";

constructor(weChatBot: Wechaty) {
this.weChatBot = weChatBot;
}
Expand Down Expand Up @@ -171,8 +173,8 @@ export class ChatBot {
}
replyCallback(responseData);
}).catch((error) => {
replyCallback(this.constructResponseData(Constants.responseStatus.failed, this.errorResponse));
Logger.error(error);
replyCallback(this.constructResponseData(Constants.responseStatus.failed, error.message));
});
}

Expand All @@ -194,7 +196,7 @@ export class ChatBot {
await chatbot.askResponse(requestId, replyCallback, intervalId)
}, 2000);
}).catch((error) => {
replyCallback(this.constructResponseData(Constants.responseStatus.failed, error.message));
replyCallback(this.constructResponseData(Constants.responseStatus.failed, this.errorResponse));
Logger.error(error);
});
}
Expand Down

0 comments on commit cc9eaa5

Please sign in to comment.