Skip to content

Commit 0401f65

Browse files
committed
SimpleChatTC:Raise Error on Ai Chat server handshake NotOk resp
1 parent acce0ce commit 0401f65

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/server/public_simplechat/simplechat.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,13 @@ class SimpleChat {
742742
* @param {HTMLDivElement} elDivChat - used to show chat response as it is being generated/recieved in streaming mode
743743
*/
744744
async handle_chat_hs(baseURL, apiEP, elDivChat) {
745+
class ChatHSError extends Error {
746+
constructor(/** @type {string} */message) {
747+
super(message);
748+
this.name = 'ChatHSError'
749+
}
750+
}
751+
745752
let theUrl = ApiEP.Url(baseURL, apiEP);
746753
let theBody = this.request_jsonstr(apiEP);
747754
console.debug(`DBUG:SimpleChat:${this.chatId}:HandleChatHS:${theUrl}:ReqBody:${theBody}`);
@@ -754,7 +761,7 @@ class SimpleChat {
754761
});
755762

756763
if (resp.status >= 300) {
757-
764+
throw new ChatHSError(`HandleChatHS:GotResponse:NotOk:${resp.status}:${resp.statusText}`);
758765
}
759766

760767
return this.handle_response(resp, apiEP, elDivChat);

0 commit comments

Comments
 (0)