mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-14 00:16:21 +00:00
Slight improvement to error handlers in frontend
This commit is contained in:
parent
762ef3141c
commit
a0ab3d436e
@ -44,7 +44,7 @@ page.onAxiosError = error => {
|
||||
const statusText = cloudflareErrors[error.response.status] || error.response.statusText
|
||||
const description = error.response.data && error.response.data.description
|
||||
? error.response.data.description
|
||||
: 'There was an error with the request, please check the console for more information.'
|
||||
: 'There was an error with the request.\nPlease check the console for more information.'
|
||||
|
||||
return swal(`${error.response.status} ${statusText}`, description, 'error')
|
||||
}
|
||||
|
@ -112,7 +112,10 @@ page.onError = error => {
|
||||
console.error(error)
|
||||
|
||||
const content = document.createElement('div')
|
||||
content.innerHTML = `<code>${error.toString()}</code>`
|
||||
content.innerHTML = `
|
||||
<p><code>${error.toString()}</code></p>
|
||||
<p>Please check your console for more information.</p>
|
||||
`
|
||||
return swal({
|
||||
title: 'An error occurred!',
|
||||
icon: 'error',
|
||||
@ -140,7 +143,7 @@ page.onAxiosError = error => {
|
||||
const statusText = cloudflareErrors[error.response.status] || error.response.statusText
|
||||
const description = error.response.data && error.response.data.description
|
||||
? error.response.data.description
|
||||
: 'There was an error with the request, please check the console for more information.'
|
||||
: 'There was an error with the request.\nPlease check the console for more information.'
|
||||
|
||||
return swal(`${error.response.status} ${statusText}`, description, 'error')
|
||||
}
|
||||
|
@ -90,7 +90,10 @@ page.onError = error => {
|
||||
console.error(error)
|
||||
|
||||
const content = document.createElement('div')
|
||||
content.innerHTML = `<code>${error.toString()}</code>`
|
||||
content.innerHTML = `
|
||||
<p><code>${error.toString()}</code></p>
|
||||
<p>Please check your console for more information.</p>
|
||||
`
|
||||
return swal({
|
||||
title: 'An error occurred!',
|
||||
icon: 'error',
|
||||
@ -120,7 +123,7 @@ page.onAxiosError = (error, cont) => {
|
||||
if (!cont) {
|
||||
const description = error.response.data && error.response.data.description
|
||||
? error.response.data.description
|
||||
: 'There was an error with the request, please check the console for more information.'
|
||||
: 'There was an error with the request.\nPlease check the console for more information.'
|
||||
return swal(`${error.response.status} ${statusText}`, description, 'error')
|
||||
} else if (error.response.data && error.response.data.description) {
|
||||
return error.response
|
||||
|
@ -21,6 +21,22 @@ const page = {
|
||||
// Disable video.js telemetry (should already be disabled by default since v7 though)
|
||||
window.HELP_IMPROVE_VIDEOJS = false
|
||||
|
||||
// Handler for regular JS errors
|
||||
page.onError = error => {
|
||||
console.error(error)
|
||||
|
||||
const content = document.createElement('div')
|
||||
content.innerHTML = `
|
||||
<p><code>${error.toString()}</code></p>
|
||||
<p>Please check your console for more information.</p>
|
||||
`
|
||||
return swal({
|
||||
title: 'An error occurred!',
|
||||
icon: 'error',
|
||||
content
|
||||
})
|
||||
}
|
||||
|
||||
// Handler for Axios errors
|
||||
page.onAxiosError = error => {
|
||||
// Better Cloudflare errors
|
||||
@ -125,7 +141,8 @@ page.reloadVideo = () => {
|
||||
page.toggleReloadBtn(true)
|
||||
}).catch(error => {
|
||||
page.toggleReloadBtn(true)
|
||||
page.onAxiosError(error)
|
||||
if (typeof error.response !== 'undefined') page.onAxiosError(error)
|
||||
else page.onError(error)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user