You have the following class for the error messages customizing:
public class CustomErrorMessage {
private int statusCode;
private String message;
public CustomErrorMessage(
int statusCode,
String message) {
this.statusCode = statusCode;
this.message = message;
}
// getters ...
}
Also you have CustomException.class:
public class CustomException extends RuntimeException {
public CustomException(String message) {
super(message);
}
}
What should the following class made for this Custom Exception handling return?
@ExceptionHandler(CustomException.class)
public ResponseEntity<CustomErrorMessage> handleFlightNotFound(
FlightNotFoundException e, WebRequest request) {
CustomErrorMessage body = new CustomErrorMessage(
HttpStatus.BAD_REQUEST.value(),
e.getMessage());
return //the result
}