{"record":{"id":"45d092b74d0ecf8b","repo":"PanJiaChen/vue-admin-template","slug":"new-error-res-message-error","errorCode":null,"errorMessage":"new Error(res.message || 'Error')","messagePattern":"new Error\\(res\\.message \\|\\| 'Error'\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/utils/request.js","lineNumber":69,"sourceCode":"        message: res.message || 'Error',\n        type: 'error',\n        duration: 5 * 1000\n      })\n\n      // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;\n      if (res.code === 50008 || res.code === 50012 || res.code === 50014) {\n        // to re-login\n        MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', {\n          confirmButtonText: 'Re-Login',\n          cancelButtonText: 'Cancel',\n          type: 'warning'\n        }).then(() => {\n          store.dispatch('user/resetToken').then(() => {\n            location.reload()\n          })\n        })\n      }\n      return Promise.reject(new Error(res.message || 'Error'))\n    } else {\n      return res\n    }\n  },\n  error => {\n    console.log('err' + error) // for debug\n    Message({\n      message: error.message,\n      type: 'error',\n      duration: 5 * 1000\n    })\n    return Promise.reject(error)\n  }\n)\n\nexport default service\n","sourceCodeStart":51,"sourceCodeEnd":86,"githubUrl":"https://github.com/PanJiaChen/vue-admin-template/blob/4c18a3f47bdb417ad8a25f09910f848cb574dee2/src/utils/request.js#L51-L86","documentation":"Rejection error created in the response interceptor after a non-20000 business code was already surfaced via Message; it propagates the server's 'message' (or the 'Error' sentinel when absent) to the caller's .catch so the promise chain does not silently treat the failed response as success.","triggerScenarios":"Thrown at src/utils/request.js:69 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Catch the rejection in the calling code and handle the specific business error code","Have the backend return meaningful 'message' values so the propagated Error is informative","Centralize handling of auth codes (50008/50012/50014) to avoid duplicate handling at call sites"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c18a3f47bdb417ad8a25f09910f848cb574dee2","analyzedAt":"2026-09-02T02:49:53.558Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}