Skip to content

Commit ac8842f

Browse files
author
Khanna
committed
2 parents 3485604 + 6911058 commit ac8842f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

frontend/src/components/chat/Chat.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ const Chat = ({ setPage }) => {
137137
);
138138

139139
if (!response.ok) {
140-
throw new Error(`HTTP error! status: ${response.status}`);
140+
const error =await response.json();
141+
console.log("response", error);
142+
throw new Error(error || `HTTP error! status: ${response.status}`);
141143
}
142144

143145
const data = await response.json();
@@ -151,8 +153,8 @@ const Chat = ({ setPage }) => {
151153
},
152154
]);
153155
} catch (error) {
154-
console.error("Error sending message:", error);
155-
toast.error("Failed to send message. Please try again.");
156+
console.error("Error sending message:", error.message);
157+
toast.error(error.message);
156158
} finally {
157159
setIsLoading(false);
158160
}

0 commit comments

Comments
 (0)