Skip to content

feat: Add global exception handler #7222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

liuzhenghua
Copy link
Contributor

What problem does this PR solve?

Add Global Exception Hanlder.

In the request.ts file, for all responses except 413 and 504, the code attempts to parse the body as JSON. If an error occurs during this process, the response in the errorHandler will be null, and the frontend will not display any error messages.
image

For responses where the body is JSON but the HTTP status code is ≥ 400, the umi-request library does not parse the body into the data property of the response. As a result, downstream code may encounter an undefined error when trying to access data.code. In such cases, the entire error object should be returned, as it contains the data property with the value of the response body.
image

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. 💞 feature Feature request, pull request that fullfill a new feature. 🧰 typescript Pull requests that update Typescript code labels Apr 23, 2025
@KevinHuSh
Copy link
Collaborator

Appreciations!
By our evaluations, this feature is not going to be merged into main branch.

@KevinHuSh KevinHuSh closed this May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💞 feature Feature request, pull request that fullfill a new feature. size:M This PR changes 30-99 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants