Skip to content

Commit

Permalink
Raise exception for response codes outside range 200-299 (#1755)
Browse files Browse the repository at this point in the history
GitHub pages return valid HTML page when an element was removed.

This adds a check for return code to not inject returned HTML if the return code is outside range 200-299.

Co-authored-by: Daniel McCloy <dan@mccloy.info>
  • Loading branch information
Czaki and drammock authored May 21, 2024
1 parent 48e4c01 commit e0c5ec3
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
<script>
document.write(`<aside class="bd-header-announcement d-print-none" aria-label="{{ banner_label }}"></aside>`);
fetch("{{ theme_announcement }}")
.then(res => {return res.text();})
.then(res => {
if (!res.ok){
throw new Error("Error loading announcement banner:\n" + res.status);
}
return res.text();})
.then(data => {
if (data.length === 0) {
console.log("[PST]: Empty announcement at: {{ theme_announcement }}");
Expand Down

0 comments on commit e0c5ec3

Please sign in to comment.