You need to create your own exception like in the example below. You want all your YourExcepNameException exceptions to generate the same HttpStatus code, for example, NOT_FOUND in the response. How can you do it?
Java
class YourExcepNameException extends RuntimeException {
// ...
}
Kotlin
class YourExcepNameException : RuntimeException() {
// ...
}