Skip to content

Commit

Permalink
fix(hub): always display an alert when not able to subscribe using th…
Browse files Browse the repository at this point in the history
…e debug UI
  • Loading branch information
dunglas committed Aug 12, 2022
1 parent e16de2e commit 78afbb9
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions public/app.js
Expand Up @@ -16,9 +16,21 @@
const $subscriptionsForm = document.forms.subscriptions;

const error = (e) => {
const message = e.toString();
console.error(e);
alert(message);
console.log(e);

if (e.toString !== Object.prototype.toString) {
alert(e.toString());

return;
}

if (e.statusText) {
alert(e.statusText);

return;
}

alert('An error occured, details have been logged.');
};

const getHubUrl = (resp) => {
Expand Down Expand Up @@ -139,7 +151,7 @@ foo`;
li.querySelector("pre").textContent = e.data;
ol.firstChild ? ol.insertBefore(li, ol.firstChild) : ol.appendChild(li);
};
updateEventSource.onerror = console.log;
updateEventSource.onerror = error;
this.elements.unsubscribe.disabled = false;
};
$subscribeForm.elements.unsubscribe.onclick = function (e) {
Expand Down Expand Up @@ -240,7 +252,7 @@ foo`;

document.getElementById(s.id).remove();
};
subscriptionEventSource.onerror = console.log;
subscriptionEventSource.onerror = error;

$subscriptionsForm.elements.unsubscribe.disabled = false;
} catch (e) {
Expand Down

0 comments on commit 78afbb9

Please sign in to comment.