From 52d5e13834c7c88efb5fc205ba725285c210baab Mon Sep 17 00:00:00 2001
From: Thomas Belin <me@thomasbelin.fr>
Date: Thu, 18 Jan 2024 18:18:04 +0100
Subject: [PATCH] refactor: Improve conversation error reports

---
 src/script/conversation/ConversationRepository.ts | 8 +++-----
 src/script/error/BaseError.ts                     | 4 +---
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/script/conversation/ConversationRepository.ts b/src/script/conversation/ConversationRepository.ts
index 01a66f16893..9bb84fac350 100644
--- a/src/script/conversation/ConversationRepository.ts
+++ b/src/script/conversation/ConversationRepository.ts
@@ -2810,11 +2810,9 @@ export class ConversationRepository {
 
       const isExpectedType = typesInSelfConversation.includes(type);
       if (!isExpectedType) {
-        return Promise.reject(
-          new ConversationError(
-            ConversationError.TYPE.WRONG_CONVERSATION,
-            ConversationError.MESSAGE.WRONG_CONVERSATION,
-          ),
+        throw new ConversationError(
+          ConversationError.TYPE.WRONG_CONVERSATION,
+          ConversationError.MESSAGE.WRONG_CONVERSATION,
         );
       }
     }
diff --git a/src/script/error/BaseError.ts b/src/script/error/BaseError.ts
index 46c031db0df..b8dd37f5f32 100644
--- a/src/script/error/BaseError.ts
+++ b/src/script/error/BaseError.ts
@@ -27,11 +27,9 @@ export class BaseError extends Error {
   type: BASE_ERROR_TYPE | string;
 
   constructor(type: BASE_ERROR_TYPE | string, message: string) {
-    super();
+    super(message);
 
     this.type = type;
-    this.message = message;
-    this.stack = new Error().stack;
     this.name = this.constructor.name;
   }