{"record":{"id":"01cbb88a252674c2","repo":"PanJiaChen/vue-admin-template","slug":"res-message-error","errorCode":null,"errorMessage":"res.message || 'Error'","messagePattern":"res\\.message \\|\\| 'Error'","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/utils/request.js","lineNumber":51,"sourceCode":"// response interceptor\nservice.interceptors.response.use(\n  /**\n   * If you want to get http information such as headers or status\n   * Please return  response => response\n  */\n\n  /**\n   * Determine the request status by custom code\n   * Here is just an example\n   * You can also judge the status by HTTP Status Code\n   */\n  response => {\n    const res = response.data\n\n    // if the custom code is not 20000, it is judged as an error.\n    if (res.code !== 20000) {\n      Message({\n        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'))","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/PanJiaChen/vue-admin-template/blob/4c18a3f47bdb417ad8a25f09910f848cb574dee2/src/utils/request.js#L33-L69","documentation":"Generic error fallback shown in the axios response interceptor when the backend returns a custom business code other than 20000 and the response body carries no 'message' field; 'Error' is a sentinel placeholder for a missing server-side error description.","triggerScenarios":"Thrown at src/utils/request.js:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the backend always returns a descriptive 'message' field alongside non-20000 business codes","Inspect the network response payload to identify the actual business error code and its cause","Handle specific business codes explicitly before falling back to the generic message"],"exampleFix":null,"handlingStrategy":"fallback","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"}