@Test public void testComposeErrorMessage() { Exception ex = new IllegalDataException("wrong data", new IllegalArgumentException("wrong number format")); String errMsg = ExceptionTranslator.composeErrorMessage(ErrorTestEnum.E200, ex); assertThat(errMsg, is("E200: error in billing (IllegalArgumentException: wrong number format)")); errMsg = ExceptionTranslator.composeErrorMessage(InternalErrorEnum.E100, ex); assertThat(errMsg, is("E100: unspecified error (IllegalArgumentException: wrong number format)")); }
public static String composeErrorMessage(ErrorExtEnum error, Exception ex) { Assert.notNull(error, "the error must not be null"); Assert.notNull(ex, "the ex must not be null"); if (error == InternalErrorEnum.E100) { Throwable rootException = ExceptionUtils.getRootCause(ex); if (ex != rootException) { error = getError(rootException); } } return error.toString() + ": " + error.getErrDesc() + " (" + getRootExceptionMessage(ex) + ")"; }
ExceptionTranslator implements Processor { public static String composeErrorMessage(ErrorExtEnum error, Exception ex) { Assert.notNull(error, "the error must not be null"); Assert.notNull(ex, "the ex must not be null"); if (error == InternalErrorEnum.E100) { Throwable rootException = ExceptionUtils.getRootCause(ex); if (ex != rootException) { error = getError(rootException); } } return error.toString() + ": " + error.getErrDesc() + " (" + getRootExceptionMessage(ex) + ")"; } }
ExceptionTranslator implements Processor { public static String composeErrorMessage(ErrorExtEnum error, Exception ex) { Assert.notNull(error, "the error must not be null"); Assert.notNull(ex, "the ex must not be null"); if (error == InternalErrorEnum.E100) { Throwable rootException = ExceptionUtils.getRootCause(ex); if (ex != rootException) { error = getError(rootException); } } return error.toString() + ": " + error.getErrDesc() + " (" + getRootExceptionMessage(ex) + ")"; } private  ExceptionTranslator(); }
ExceptionTranslator implements Processor { public static String composeErrorMessage(ErrorExtEnum error, Exception ex) { Assert.notNull(error, "the error must not be null"); Assert.notNull(ex, "the ex must not be null"); if (error == InternalErrorEnum.E100) { Throwable rootException = ExceptionUtils.getRootCause(ex); if (ex != rootException) { error = getError(rootException); } } return error.toString() + ": " + error.getErrDesc() + " (" + getRootExceptionMessage(ex) + ")"; } private  ExceptionTranslator(); static ExceptionTranslator getInstance(); @Override void process(Exchange exchange); static String composeErrorMessage(ErrorExtEnum error, Exception ex); static ErrorExtEnum getError(Throwable ex); }
ExceptionTranslator implements Processor { public static String composeErrorMessage(ErrorExtEnum error, Exception ex) { Assert.notNull(error, "the error must not be null"); Assert.notNull(ex, "the ex must not be null"); if (error == InternalErrorEnum.E100) { Throwable rootException = ExceptionUtils.getRootCause(ex); if (ex != rootException) { error = getError(rootException); } } return error.toString() + ": " + error.getErrDesc() + " (" + getRootExceptionMessage(ex) + ")"; } private  ExceptionTranslator(); static ExceptionTranslator getInstance(); @Override void process(Exchange exchange); static String composeErrorMessage(ErrorExtEnum error, Exception ex); static ErrorExtEnum getError(Throwable ex);  }