Skip to content

Commit

Permalink
[MODFISTO-513] - Used similar logic in other methods
Browse files Browse the repository at this point in the history
  • Loading branch information
azizbekxm committed Dec 24, 2024
1 parent ec16f13 commit 1bd77aa
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/main/java/org/folio/rest/exception/HttpException.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ public HttpException(int code, String message) {
public HttpException(int code, String message, Throwable cause) {
super(message, cause);
this.code = code;
var ec = code == 409 ? CONFLICT : GENERIC_ERROR_CODE;
Parameter causeParam = new Parameter().withKey("cause").withValue(cause.getMessage());
Error error = new Error()
.withCode(ErrorCodes.GENERIC_ERROR_CODE.getCode())
.withCode(ec.getCode())
.withMessage(message)
.withParameters(List.of(causeParam));
this.errors = new Errors()
Expand All @@ -43,17 +44,10 @@ public HttpException(int code, String message, Throwable cause) {
public HttpException(int code, Throwable cause) {
super(cause.getMessage(), cause);
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(cause.getMessage())))
.withTotalRecords(1);
}

public HttpException(int code, ErrorCodes errCodes) {
super(errCodes.getDescription());
this.errors = new Errors()
.withErrors(List.of(new Error().withCode(errCodes.getCode()).withMessage(errCodes.getDescription())))
.withErrors(List.of(new Error().withCode(ec.getCode()).withMessage(cause.getMessage())))
.withTotalRecords(1);
this.code = code;
}

public HttpException(int code, Error error) {
Expand Down

0 comments on commit 1bd77aa

Please sign in to comment.