diff --git a/src/main/java/org/folio/rest/exception/HttpException.java b/src/main/java/org/folio/rest/exception/HttpException.java index 3d3ca912..4b858aa3 100644 --- a/src/main/java/org/folio/rest/exception/HttpException.java +++ b/src/main/java/org/folio/rest/exception/HttpException.java @@ -1,11 +1,15 @@ package org.folio.rest.exception; +import static org.folio.rest.util.ErrorCodes.CONFLICT; +import static org.folio.rest.util.ErrorCodes.GENERIC_ERROR_CODE; + import org.apache.commons.lang3.StringUtils; import org.folio.rest.jaxrs.model.Error; import org.folio.rest.jaxrs.model.Errors; import org.folio.rest.jaxrs.model.Parameter; import org.folio.rest.util.ErrorCodes; +import java.util.Collections; import java.util.List; public class HttpException extends RuntimeException { @@ -17,8 +21,9 @@ public class HttpException extends RuntimeException { public HttpException(int code, String message) { super(StringUtils.isNotEmpty(message) ? message : ErrorCodes.GENERIC_ERROR_CODE.getDescription()); this.code = code; + var ec = code == 409 ? CONFLICT : GENERIC_ERROR_CODE; this.errors = new Errors() - .withErrors(List.of(new Error().withCode(ErrorCodes.GENERIC_ERROR_CODE.getCode()).withMessage(message))) + .withErrors(Collections.singletonList(new Error().withCode(ec.getCode()).withMessage(message))) .withTotalRecords(1); }