diff --git a/src/js/auth.js b/src/js/auth.js index c493ecc..cbecf26 100644 --- a/src/js/auth.js +++ b/src/js/auth.js @@ -37,8 +37,28 @@ page.unhide = () => { if (floatingBtn) floatingBtn.classList.remove('is-hidden') } +// Handler for regular JS errors +page.onError = error => { + console.error(error) + + const content = document.createElement('div') + content.innerHTML = ` +

${error.toString()}

+

Please check your console for more information.

+ ` + return swal({ + title: 'An error occurred!', + icon: 'error', + content + }) +} + // Handler for Axios errors page.onAxiosError = error => { + if (!error.response) { + return page.onError(error) + } + const statusText = page.cloudflareErrors[error.response.status] || error.response.statusText const description = error.response.data && error.response.data.description ? error.response.data.description diff --git a/src/js/dashboard.js b/src/js/dashboard.js index e20dab1..272e857 100644 --- a/src/js/dashboard.js +++ b/src/js/dashboard.js @@ -147,6 +147,10 @@ page.onError = error => { // Handler for Axios errors page.onAxiosError = error => { + if (!error.response) { + return page.onError(error) + } + const statusText = page.cloudflareErrors[error.response.status] || error.response.statusText const description = error.response.data && error.response.data.description ? error.response.data.description diff --git a/src/js/file.js b/src/js/file.js index 84e2268..8f5d034 100644 --- a/src/js/file.js +++ b/src/js/file.js @@ -55,6 +55,10 @@ page.onError = error => { // Handler for Axios errors page.onAxiosError = error => { + if (!error.response) { + return page.onError(error) + } + const statusText = page.cloudflareErrors[error.response.status] || error.response.statusText const description = error.response.data && error.response.data.description diff --git a/src/js/home.js b/src/js/home.js index c1fe400..1ce1fbe 100644 --- a/src/js/home.js +++ b/src/js/home.js @@ -118,6 +118,10 @@ page.onError = error => { // Handler for Axios errors page.onAxiosError = error => { + if (!error.response) { + return page.onError(error) + } + const statusText = page.cloudflareErrors[error.response.status] || error.response.statusText const description = error.response.data && error.response.data.description ? error.response.data.description diff --git a/src/js/player.js b/src/js/player.js index b84e549..69be92e 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -51,6 +51,10 @@ page.onError = error => { // Handler for Axios errors page.onAxiosError = error => { + if (!error.response) { + return page.onError(error) + } + const statusText = page.cloudflareErrors[error.response.status] || error.response.statusText const description = error.response.data && error.response.data.description