remove last message if 429
This commit is contained in:
parent
49b94d9e13
commit
f1b9abb4e0
@ -157,10 +157,21 @@ function displayAlert(type, message) {
|
|||||||
|
|
||||||
// Handles error responses based on status code
|
// Handles error responses based on status code
|
||||||
function handleErrorResponse(status) {
|
function handleErrorResponse(status) {
|
||||||
|
const messages = document.getElementById('messages');
|
||||||
|
const lastMessage = messages.lastElementChild;
|
||||||
|
|
||||||
if (status === 429) {
|
if (status === 429) {
|
||||||
displayAlert('error', 'Sorry, I am currently too busy at the moment!');
|
displayAlert('error', 'Sorry, I am currently too busy at the moment!');
|
||||||
|
// Remove the last user message if the status is 429
|
||||||
|
if (lastMessage && lastMessage.classList.contains('user')) {
|
||||||
|
messages.removeChild(lastMessage);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
displayMessage('Error: ' + status, 'assistant');
|
displayMessage('Error: ' + status, 'assistant');
|
||||||
|
// Remove the last user message for any other errors
|
||||||
|
if (lastMessage && lastMessage.classList.contains('user')) {
|
||||||
|
messages.removeChild(lastMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user