PacktPublishing / PacktPublishing/Microservices-with-Spring-Boot-and-Spring-Cloud-Fourth-Edition
Bad Request error handling issue
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 47
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
If there's no required parameter from rest call, the GlobalControllerExceptionhandler will never capture it since BadQuestException is never instantiated and thrown. To capture 400 error, you have to do this (using MissingRequestValueException):
@ResponseStatus(BAD_REQUEST)
@ExceptionHandler(MissingRequestValueException.class)
public @ResponseBody HttpErrorInfo handleBadRequestExceptions(
ServerHttpRequest request, MissingRequestValueException ex) {
return createHttpErrorInfo(BAD_REQUEST, request, ex);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating GlobalControllerExceptionhandler and review how missing required REST parameters are currently handled. Check the existing BadRequestException handling and add coverage for MissingRequestValueException as described in the issue. Done means a request missing a required parameter is captured and returns a 400 response with HttpErrorInfo.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100