@Test public void shouldHandleMdsExceptions() throws Exception { for (MdsException exception : exceptions) { assertEquals("Exception class " + exception.getClass(), String.format("key:%s", exception.getMessageKey()), controller.handleMdsException(exception) ); } }
@ExceptionHandler(MdsException.class) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody public String handleMdsException(final MdsException exception) throws IOException { LOGGER.error("Error: " + exception.getMessage(), exception); if (exception.getMessageKey() == null) { return "error"; } else if (exception.getParams() == null) { return String.format("key:%s", exception.getMessageKey()); } else { return String.format("key:%s\nparams:%s", exception.getMessageKey(), exception.getParams()); } }
MdsController { @ExceptionHandler(MdsException.class) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody public String handleMdsException(final MdsException exception) throws IOException { LOGGER.error("Error: " + exception.getMessage(), exception); if (exception.getMessageKey() == null) { return "error"; } else if (exception.getParams() == null) { return String.format("key:%s", exception.getMessageKey()); } else { return String.format("key:%s\nparams:%s", exception.getMessageKey(), exception.getParams()); } } }
MdsController { @ExceptionHandler(MdsException.class) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody public String handleMdsException(final MdsException exception) throws IOException { LOGGER.error("Error: " + exception.getMessage(), exception); if (exception.getMessageKey() == null) { return "error"; } else if (exception.getParams() == null) { return String.format("key:%s", exception.getMessageKey()); } else { return String.format("key:%s\nparams:%s", exception.getMessageKey(), exception.getParams()); } }  }
MdsController { @ExceptionHandler(MdsException.class) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody public String handleMdsException(final MdsException exception) throws IOException { LOGGER.error("Error: " + exception.getMessage(), exception); if (exception.getMessageKey() == null) { return "error"; } else if (exception.getParams() == null) { return String.format("key:%s", exception.getMessageKey()); } else { return String.format("key:%s\nparams:%s", exception.getMessageKey(), exception.getParams()); } }  @ExceptionHandler(MdsException.class) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody String handleMdsException(final MdsException exception); }
MdsController { @ExceptionHandler(MdsException.class) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody public String handleMdsException(final MdsException exception) throws IOException { LOGGER.error("Error: " + exception.getMessage(), exception); if (exception.getMessageKey() == null) { return "error"; } else if (exception.getParams() == null) { return String.format("key:%s", exception.getMessageKey()); } else { return String.format("key:%s\nparams:%s", exception.getMessageKey(), exception.getParams()); } }  @ExceptionHandler(MdsException.class) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody String handleMdsException(final MdsException exception);  }