adamsaghy commented on code in PR #3471: URL: https://github.com/apache/fineract/pull/3471#discussion_r1338281323
########## fineract-core/src/main/java/org/apache/fineract/batch/exception/ErrorHandler.java: ########## @@ -71,24 +88,68 @@ private <T extends RuntimeException> ExceptionMapper<T> findMostSpecificExceptio return (ExceptionMapper<T>) defaultExceptionMapper; } - private <T> Set<T> createSet(T[] array) { - if (array == null) { - return Set.of(); - } else { - return Set.of(array); - } - } - /** * Returns an object of ErrorInfo type containing the information regarding the raised error. * * @param exception * @return ErrorInfo */ - public ErrorInfo handle(final RuntimeException exception) { + public ErrorInfo handle(@NotNull RuntimeException exception) { ExceptionMapper<RuntimeException> exceptionMapper = findMostSpecificExceptionHandler(exception); Response response = exceptionMapper.toResponse(exception); + MultivaluedMap<String, Object> headers = response.getHeaders(); + Set<Header> batchHeaders = headers == null ? null + : headers.keySet().stream().map(e -> new Header(e, response.getHeaderString(e))).collect(Collectors.toSet()); return new ErrorInfo(response.getStatus(), ((FineractExceptionMapper) exceptionMapper).errorCode(), - JSON_HELPER.toJson(response.getEntity())); + JSON_HELPER.toJson(response.getEntity()), batchHeaders); + } + + public RuntimeException getMappable(@NotNull Throwable thr) { + return getMappable(thr, null, null, null); + } + + public RuntimeException getMappable(@NotNull Throwable t, String msgCode, String defaultMsg, String param, Review Comment: We discussed and it was not new thing, but put them to a common place. Later it might be further improved. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@fineract.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org