change errorMessages to handle error message of restful api
- Dominant language
- JavaScript
- Stars
- 27.2k
- Forks
- 5.6k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 46
Description
restful apis usually return response of `40x` with a body explaining the error reason, and sometimes these error response even can be what we want to get in a `20x` response.
and in Shields, all these `40x` responses are treated as unusable exceptions and in `foo.service.js` it's hard to handle these responses.
For example to solve #4811 , I plan to get the SHA of the file and get the size through `git/blobs/:sha` endpoint (it supports blobs up to 100 megabytes in size). However, I find that the response code from `contents/` endpoint of those files larger than 1MB are `403` so they can't be handled in `github-size.service.js`.
Why not change `errorMessages` from `{[prop: number]: string}` to `{[prop: number]: (body: string) => string}` so many error message can be better handled ?
Contributor guide
Research direction
Start by locating errorMessages and reading foo.service.js and github-size.service.js to understand how 40x responses are converted into exceptions. Check the existing service tests or error-handling tests before changing the behavior. Done means callers can use an error response body when needed while existing error messages continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100