mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
fix: frontend errors handling
This commit is contained in:
parent
52299408ae
commit
e0d0694a30
@ -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 = `
|
||||
<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 => {
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user