vitesse-yitisheng-web/task_detail.md

1.1 KiB

Task Detail

2025-12-18 Session 5

Execution Reason

User reported that the frontend was displaying a generic "Request failed with status code 401" error instead of the specific "用户不存在" message returned by the backend in the data.message field.

Execution Process

  1. Analysis: Examined src/service/request/index.ts. The response interceptor's error handler (onRejected) was hardcoding messages for 401, 403, etc., ignoring the message field from the backend response body (error.response.data.message).
  2. Fix: Updated the error handling logic to prioritize error.response.data?.message if it exists. If not, it falls back to the default status code descriptions.
  3. Refinement: Ensured Promise.reject returns a new Error object with the refined message, so calling code (try/catch) receives the correct error text.

Execution Result

  • The application will now display the specific error message returned by the backend (e.g., "用户不存在") in the global message toast and in catch blocks, improving the user experience and debugging capability.