From 11b042a8c3cb51dc3e8669d31a007f013471e847 Mon Sep 17 00:00:00 2001 From: Max Kammler Date: Wed, 8 Feb 2023 09:50:24 +0100 Subject: [PATCH] pass OpenAI error directly to user --- src/handlers.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/handlers.ts b/src/handlers.ts index 6a1fa16..e7098bf 100644 --- a/src/handlers.ts +++ b/src/handlers.ts @@ -122,7 +122,12 @@ export default class CommandHandler { return; } - const result = await sendChatGPTMessage(this.chatGPT, await bodyWithoutPrefix, storedConversation); + const result = await sendChatGPTMessage(this.chatGPT, await bodyWithoutPrefix, storedConversation) + .catch((error) => { + LogService.warn(`OpenAPI Error: ${error}`); + sendError(this.client, "Sorry, there was an error using the OpenAI-API. Details: " + error, roomId, event.event_id); + return; + }); await Promise.all([ this.client.setTyping(roomId, false, 500), sendReply(this.client, roomId, this.getRootEventId(event), `${result.response}`, MATRIX_THREADS, MATRIX_RICH_TEXT)