I'm tasked with removing functionality given by @ControllerAdvice(basePackages = {"com.bla.controller"}) located in an old applications. This functionality became outdated, creating some unexpected error handling issues, after another "global" functionality utilizing @ControllerAdvice got installed by a separate team. While this "global" functionality covers most needs, the old application still has a need for custom error handling, but without @ControllerAdvice. My knowledge of Spring Annotations is very limited, and I'm hoping that someone may have a good idea what can be used instead so that the old application would have awareness where to send errors for error handling. Here is an implementation sample from the file utilizing @ControllerAdvice(basePackages = {"com.bla.controller"}) notation showing both custom and basic usage in the old application:
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(ResourcePageException.class)
public String notFound(Model model, ResourcePageException exception) {
setAttributes(model);
populateModel(model, exception);
return Mapping.NO_RESULTS_VIEW;
}
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoCustomSearchResultsRestException.class)
public ResponseEntity<Object> locationLookupRestError(NoCustomSearchResultsRestException exception) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(exception.getModel());
}