@Test public void testEmptyMap() { SyndesisConnectorException sce = new SyndesisConnectorException("SQL_CONNECTOR_ERROR", "error msg test"); ErrorStatusInfo info = ErrorMapper.mapError(sce, Collections.emptyMap(), 200); assertThat(info.getHttpResponseCode()).isEqualTo(200); assertThat(info.getCategory()).isEqualTo("SQL_CONNECTOR_ERROR"); assertThat(info.getMessage()).isEqualTo("error msg test"); }
public static ErrorStatusInfo mapError(final Exception exception, final Map<String, Integer> httpResponseCodeMappings, final Integer defaultResponseCode) { SyndesisConnectorException sce; if (isOrCausedBySyndesisConnectorException(exception)) { sce = extract(exception); } else { sce = fromRuntimeException(exception, httpResponseCodeMappings.keySet()); } if (sce == null) { sce = SyndesisConnectorException.from(exception); } Integer responseCode = httpResponseCodeMappings.get(sce.getCategory()) != null ? httpResponseCodeMappings.get(sce.getCategory()): defaultResponseCode; return new ErrorStatusInfo(responseCode, sce.getCategory(), Optional.ofNullable(sce.getMessage()).orElse("no message"), deriveErrorName(sce)); }
ErrorMapper { public static ErrorStatusInfo mapError(final Exception exception, final Map<String, Integer> httpResponseCodeMappings, final Integer defaultResponseCode) { SyndesisConnectorException sce; if (isOrCausedBySyndesisConnectorException(exception)) { sce = extract(exception); } else { sce = fromRuntimeException(exception, httpResponseCodeMappings.keySet()); } if (sce == null) { sce = SyndesisConnectorException.from(exception); } Integer responseCode = httpResponseCodeMappings.get(sce.getCategory()) != null ? httpResponseCodeMappings.get(sce.getCategory()): defaultResponseCode; return new ErrorStatusInfo(responseCode, sce.getCategory(), Optional.ofNullable(sce.getMessage()).orElse("no message"), deriveErrorName(sce)); } }
ErrorMapper { public static ErrorStatusInfo mapError(final Exception exception, final Map<String, Integer> httpResponseCodeMappings, final Integer defaultResponseCode) { SyndesisConnectorException sce; if (isOrCausedBySyndesisConnectorException(exception)) { sce = extract(exception); } else { sce = fromRuntimeException(exception, httpResponseCodeMappings.keySet()); } if (sce == null) { sce = SyndesisConnectorException.from(exception); } Integer responseCode = httpResponseCodeMappings.get(sce.getCategory()) != null ? httpResponseCodeMappings.get(sce.getCategory()): defaultResponseCode; return new ErrorStatusInfo(responseCode, sce.getCategory(), Optional.ofNullable(sce.getMessage()).orElse("no message"), deriveErrorName(sce)); } private  ErrorMapper(); }
ErrorMapper { public static ErrorStatusInfo mapError(final Exception exception, final Map<String, Integer> httpResponseCodeMappings, final Integer defaultResponseCode) { SyndesisConnectorException sce; if (isOrCausedBySyndesisConnectorException(exception)) { sce = extract(exception); } else { sce = fromRuntimeException(exception, httpResponseCodeMappings.keySet()); } if (sce == null) { sce = SyndesisConnectorException.from(exception); } Integer responseCode = httpResponseCodeMappings.get(sce.getCategory()) != null ? httpResponseCodeMappings.get(sce.getCategory()): defaultResponseCode; return new ErrorStatusInfo(responseCode, sce.getCategory(), Optional.ofNullable(sce.getMessage()).orElse("no message"), deriveErrorName(sce)); } private  ErrorMapper(); static Map<String, Integer> jsonToMap(String property); static ErrorStatusInfo mapError(final Exception exception, final Map<String, Integer> httpResponseCodeMappings,
            final Integer defaultResponseCode); }
ErrorMapper { public static ErrorStatusInfo mapError(final Exception exception, final Map<String, Integer> httpResponseCodeMappings, final Integer defaultResponseCode) { SyndesisConnectorException sce; if (isOrCausedBySyndesisConnectorException(exception)) { sce = extract(exception); } else { sce = fromRuntimeException(exception, httpResponseCodeMappings.keySet()); } if (sce == null) { sce = SyndesisConnectorException.from(exception); } Integer responseCode = httpResponseCodeMappings.get(sce.getCategory()) != null ? httpResponseCodeMappings.get(sce.getCategory()): defaultResponseCode; return new ErrorStatusInfo(responseCode, sce.getCategory(), Optional.ofNullable(sce.getMessage()).orElse("no message"), deriveErrorName(sce)); } private  ErrorMapper(); static Map<String, Integer> jsonToMap(String property); static ErrorStatusInfo mapError(final Exception exception, final Map<String, Integer> httpResponseCodeMappings,
            final Integer defaultResponseCode);  }