twentyone: show ratelimit error when ratelimited

master
justcool393 2022-11-01 16:23:51 -05:00
parent 89d5428f77
commit 0dd956ae0e
1 changed files with 12 additions and 1 deletions

View File

@ -11,6 +11,7 @@
}
function handleBlackjackResponse(xhr) {
let status;
try {
const response = JSON.parse(xhr.response);
const succeeded = xhr.status >= 200 &&
@ -19,6 +20,11 @@
!response.error;
clearResult();
status = xhr.status;
if (status == 429) {
throw new Error(response["details"]);
}
if (succeeded) {
updateBlackjackTable(response.state);
@ -36,8 +42,13 @@
"double-down": "Unable to double down.",
"buy-insurance": "Unable to buy insurance."
};
result = results[xhr.blackjackAction];
updateResult(results[xhr.blackjackAction], "danger");
if (status == 429) {
result = error.message;
}
updateResult(result, "danger");
}
}