Skip to content

Commit

Permalink
fix: Handle ABNF API errors (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
kesara authored Feb 4, 2025
1 parent df5a1d9 commit 5374514
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion static/scripts/abnf.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ function parse() {
});

fetch(request)
.then(function(response) { return response.json(); })
.then(function(response) {
if (!response.ok) {
throw new Error(`There was an issue processing your request. (HTTP Status: ${response.status})`);
}
return response.json();
})
.then(function(json) {
reset();
if (json.errors) {
Expand All @@ -96,5 +101,10 @@ function parse() {
preAbnf.textContent = json.abnf;
}
accordionAbnfParse.scrollIntoView();
})
.catch(error => {
accordionItemErrors.style.display = 'block';
preErrors.textContent = error;
resetButtons();
});
}

0 comments on commit 5374514

Please sign in to comment.