Provide a series of exception classes inherited from spring ResponseStatusException, such as BadRequestException
, NotFoundException
.
Include all 4xx exceptions.
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.czp3009:spring-errors:0.0.2'
}
org.springframework:spring-web:6.X
@RestController
@RequestMapping("/")
class GreetingController {
@GetMapping
String get(String name) {
//http code 400
if (name == null) throw new BadRequestException("Name can't be null");
return "Hello " + name;
}
}
Apache 2.0