SimpleChatTC:Raise Error on Ai Chat server handshake NotOk resp
This commit is contained in:
parent
91f39b7197
commit
6a8ced244c
|
|
@ -742,6 +742,13 @@ class SimpleChat {
|
||||||
* @param {HTMLDivElement} elDivChat - used to show chat response as it is being generated/recieved in streaming mode
|
* @param {HTMLDivElement} elDivChat - used to show chat response as it is being generated/recieved in streaming mode
|
||||||
*/
|
*/
|
||||||
async handle_chat_hs(baseURL, apiEP, elDivChat) {
|
async handle_chat_hs(baseURL, apiEP, elDivChat) {
|
||||||
|
class ChatHSError extends Error {
|
||||||
|
constructor(/** @type {string} */message) {
|
||||||
|
super(message);
|
||||||
|
this.name = 'ChatHSError'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let theUrl = ApiEP.Url(baseURL, apiEP);
|
let theUrl = ApiEP.Url(baseURL, apiEP);
|
||||||
let theBody = this.request_jsonstr(apiEP);
|
let theBody = this.request_jsonstr(apiEP);
|
||||||
console.debug(`DBUG:SimpleChat:${this.chatId}:HandleChatHS:${theUrl}:ReqBody:${theBody}`);
|
console.debug(`DBUG:SimpleChat:${this.chatId}:HandleChatHS:${theUrl}:ReqBody:${theBody}`);
|
||||||
|
|
@ -754,7 +761,7 @@ class SimpleChat {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (resp.status >= 300) {
|
if (resp.status >= 300) {
|
||||||
|
throw new ChatHSError(`HandleChatHS:GotResponse:NotOk:${resp.status}:${resp.statusText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.handle_response(resp, apiEP, elDivChat);
|
return this.handle_response(resp, apiEP, elDivChat);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue