First Committ
This commit is contained in:
25
src/error-handler/backend.ts
Executable file
25
src/error-handler/backend.ts
Executable file
@@ -0,0 +1,25 @@
|
||||
// import { i18n } from '../boot/vue-i18n'
|
||||
import { Notify } from 'quasar'
|
||||
|
||||
export default (error: any) => {
|
||||
/*
|
||||
let message = this.$i18n.t('errors.backend.undefined')
|
||||
if (error.response.data.error && error.response.data.message) {
|
||||
message = error.response.data.message
|
||||
}
|
||||
|
||||
if (error.response.data.errors) {
|
||||
const errors = Object.keys(error.response.data.errors)
|
||||
message = error.response.data.errors[errors[0]][0]
|
||||
}
|
||||
|
||||
Notify.create({
|
||||
message,
|
||||
position: 'center'
|
||||
})
|
||||
|
||||
if (message === this.$i18n.t('errors.backend.undefined')) {
|
||||
console.log(error.response)
|
||||
}
|
||||
*/
|
||||
}
|
||||
24
src/error-handler/firebase.ts
Executable file
24
src/error-handler/firebase.ts
Executable file
@@ -0,0 +1,24 @@
|
||||
import { Notify } from 'quasar'
|
||||
import store from '../store'
|
||||
// import { i18n } from '../boot/vue-i18n'
|
||||
|
||||
export default (error: any) => {
|
||||
/*
|
||||
switch (error.code) {
|
||||
case 'messaging/notifications-blocked':
|
||||
case 'messaging/permission-blocked':
|
||||
store.commit('session/fcmNotificationPromptShowed', true)
|
||||
store.commit('session/fcmNotificationsBlocked', true)
|
||||
break
|
||||
case 'messaging/token-unsubscribe-failed':
|
||||
Notify.create({
|
||||
message: i18n.t('errors.firebase.try_again'),
|
||||
position: 'center'
|
||||
})
|
||||
break
|
||||
default:
|
||||
console.error(error)
|
||||
break
|
||||
}
|
||||
*/
|
||||
}
|
||||
22
src/error-handler/graphql.ts
Executable file
22
src/error-handler/graphql.ts
Executable file
@@ -0,0 +1,22 @@
|
||||
// import { i18n } from '../boot/vue-i18n'
|
||||
import { Notify } from 'quasar'
|
||||
|
||||
export default (error: any) => {
|
||||
/*
|
||||
let message = this.$i18n.t('errors.graphql.undefined')
|
||||
|
||||
if (error[0].validation) {
|
||||
let errors = Object.keys(error[0].validation)
|
||||
message = error[0].validation[errors[0]][0]
|
||||
}
|
||||
|
||||
Notify.create({
|
||||
message,
|
||||
position: 'center'
|
||||
})
|
||||
|
||||
if (message === this.$i18n.t('errors.graphql.undefined')) {
|
||||
console.log(error.response)
|
||||
}
|
||||
*/
|
||||
}
|
||||
21
src/error-handler/index.ts
Executable file
21
src/error-handler/index.ts
Executable file
@@ -0,0 +1,21 @@
|
||||
// import Backend from './backend'
|
||||
// import Firebase from './firebase'
|
||||
import Graphql from './graphql'
|
||||
|
||||
export default (context: any, error: any) => {
|
||||
/*
|
||||
if (error.constructor.nametranslate === 'FirebaseError') {
|
||||
Firebase(error)
|
||||
return
|
||||
}
|
||||
if (error.response && error.response.data && error.response.data.backend) {
|
||||
Backend(error)
|
||||
return
|
||||
} */
|
||||
|
||||
if (error[0] && error[0].locations && error[0].validation) {
|
||||
Graphql(error)
|
||||
return
|
||||
}
|
||||
console.log('Error handler', error)
|
||||
}
|
||||
Reference in New Issue
Block a user