mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-14 08:26:22 +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 statusText = cloudflareErrors[error.response.status] || error.response.statusText
|
||||||
const description = error.response.data && error.response.data.description
|
const description = error.response.data && error.response.data.description
|
||||||
? 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')
|
return swal(`${error.response.status} ${statusText}`, description, 'error')
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,10 @@ page.onError = error => {
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
|
|
||||||
const content = document.createElement('div')
|
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({
|
return swal({
|
||||||
title: 'An error occurred!',
|
title: 'An error occurred!',
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
@ -140,7 +143,7 @@ page.onAxiosError = error => {
|
|||||||
const statusText = cloudflareErrors[error.response.status] || error.response.statusText
|
const statusText = cloudflareErrors[error.response.status] || error.response.statusText
|
||||||
const description = error.response.data && error.response.data.description
|
const description = error.response.data && error.response.data.description
|
||||||
? 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')
|
return swal(`${error.response.status} ${statusText}`, description, 'error')
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,10 @@ page.onError = error => {
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
|
|
||||||
const content = document.createElement('div')
|
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({
|
return swal({
|
||||||
title: 'An error occurred!',
|
title: 'An error occurred!',
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
@ -120,7 +123,7 @@ page.onAxiosError = (error, cont) => {
|
|||||||
if (!cont) {
|
if (!cont) {
|
||||||
const description = error.response.data && error.response.data.description
|
const description = error.response.data && error.response.data.description
|
||||||
? 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')
|
return swal(`${error.response.status} ${statusText}`, description, 'error')
|
||||||
} else if (error.response.data && error.response.data.description) {
|
} else if (error.response.data && error.response.data.description) {
|
||||||
return error.response
|
return error.response
|
||||||
|
@ -21,6 +21,22 @@ const page = {
|
|||||||
// Disable video.js telemetry (should already be disabled by default since v7 though)
|
// Disable video.js telemetry (should already be disabled by default since v7 though)
|
||||||
window.HELP_IMPROVE_VIDEOJS = false
|
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
|
// Handler for Axios errors
|
||||||
page.onAxiosError = error => {
|
page.onAxiosError = error => {
|
||||||
// Better Cloudflare errors
|
// Better Cloudflare errors
|
||||||
@ -125,7 +141,8 @@ page.reloadVideo = () => {
|
|||||||
page.toggleReloadBtn(true)
|
page.toggleReloadBtn(true)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
page.toggleReloadBtn(true)
|
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