Controller Advice
@ControllerAdvice
@ExceptionHandler(ResourceNotFoundException.class)
public ResponseEntity<?> resourceNotFound(ResourceNotFoundException ex, HttpServletRequest request) {
ErrorDetail errorDetail = new ErrorDetail();
errorDetail.setTimeStamp(new Date().getTime());
errorDetail.setStatus(HttpStatus.NOT_FOUND.value());
errorDetail.setTitle("Resource Not Found");
errorDetail.setDetail(ex.getMessage());
errorDetail.setDeveloperMessage(ex.getClass().getName());
return new ResponseEntity<>(errorDetail, null, HttpStatus.NOT_FOUND);
}
Comments