/************************ * import ************************/ const useErrorHandler = () => { const { $log, $toast, $eventBus } = useNuxtApp() // 공통 에러코드 let errProfiles = [ { code : '9999' , action : 0, desc : '기타오류', proc : {type:'toast',msg:'처리중 오류가 발생되었습니다.
지속발생시 관리자에게 문의 바랍니다.'}, after : null} ] let errObj = { code : '' , action : 0, desc : '', proc : {type:'toast',msg:'처리중 오류가 발생되었습니다.
상세오류코드: '}, after : null} /** * 공통 에러 처리 함수 * @param {*} error 에러 */ async function fnSetCommErrorHandle(error){ let code = '' let msg = '' if (error.response){ code = error.response.data.resCode msg = error.response.data.resMsg } //$log.error('[ErrorHandle][ERROR]' + JSON.stringify(error.response.data)) if(code === '1005' || code === '1006' || code === '1007' || code === '1008') { // 1005: 토큰이 없음, 1006: 토큰 만료됨, 1007: 잘못된 토큰 값, 1008: 로그아웃 처리된 토큰 값 => 강제 로그인 페이지로 이동 $eventBus.emit('SESSION_DESTORY') } // 에러로 처리 errObj.code = code if(_isEmpty(errObj.code)){ errObj = _find(errProfiles, {code:'9999'}) code = '9999' } if(errObj.proc.type === 'toast'){ let toastMsg = errObj.proc.msg toastMsg = errObj.proc.msg.concat(msg+'['+code+']') //$toast.error(toastMsg) } return false } return { fnSetCommErrorHandle } } export default useErrorHandler