update: 錯誤控制處理-印出errorMsg/errorObj
| | |
| | | }; |
| | | |
| | | function showErrorMessageBox(error:any):void{ |
| | | // console.log('error', error, error.response); |
| | | if(!_.includes(notRequireInterceptorErrorUrl,error.config.url)){ |
| | | switch (error.response.status) { |
| | | case 401: |
| | | ErrorMessageBox('登入逾時').then(()=>{ |
| | | location.href='/'; |
| | | window.$nuxt.$store.commit('localStorage/storageClear'); |
| | | location.href='/'; |
| | | }); |
| | | break; |
| | | default: |
| | | ErrorMessageBox(); |
| | | ErrorMessageBox('', error); |
| | | break; |
| | | } |
| | | |
| | |
| | | import { MessageBox } from 'element-ui'; |
| | | import { MessageBoxData } from 'element-ui/types/message-box'; |
| | | |
| | | export default function ErrorMessageBox(errorMsg?:string):Promise<MessageBoxData>{ |
| | | export default function ErrorMessageBox(errorMsg?:string, errorObj?: any):Promise<MessageBoxData>{ |
| | | errorMsg && console.info('Error: ', errorMsg); |
| | | errorObj && console.error('Error Details: ', errorObj?.response || errorObj); |
| | | |
| | | return MessageBox({ |
| | | message: errorMsg ? errorMsg:'系統發生錯誤', |
| | | message: errorMsg |
| | | ? errorMsg |
| | | : `系統發生錯誤: ${errorObj?.response?.status} <p/><p/> ${errorObj?.response?.data?.detail}`, |
| | | dangerouslyUseHTMLString: true, |
| | | showClose:false, |
| | | showConfirmButton:true, |
| | | confirmButtonText:'確認', |