I've a problem returning HTTP Messages when an exception is thrown. I'm using @ResponseStatus annotation to handle the HTTP Status code, it shows ok but the message is ignored.
Custom Exception:
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR, reason = "An error ocurred while trying to
retrieve the instruments.")
public class InstrumentsNotFoundException extends RuntimeException {
private static final Logger logger = LoggerFactory.getLogger(InstrumentsNotFoundException.class);
public InstrumentsNotFoundException(String errorMessage) {
super(errorMessage);
logger.error(errorMessage);
}
Run Code Online (Sandbox Code Playgroud)
Controller:
@GetMapping({ "/portfolio/" })
public List<Instrument> getAll() {
try {
List<Instrument> instruments= portfolioYieldProcessor.getPortfolio();
return instruments; …Run Code Online (Sandbox Code Playgroud)