Skip to content

Commit

Permalink
chore: change argumention for apiexception
Browse files Browse the repository at this point in the history
  • Loading branch information
rkpattnaik780 committed Mar 24, 2023
1 parent 7833f99 commit 7305c67
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/main/java/io/managed/services/test/client/BaseApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ protected BaseApi() {
private <A> A handleException(ThrowingSupplier<A, Exception> f) throws ApiGenericException {
try {
return f.get();
} catch (ApiGenericException e) {
} catch (ApiGenericException e) {
throw e;
} catch (Exception e) {
log.info(e);

var ex = toApiException(e);
if (ex != null) {
log.info(ex);
throw ex;
throw ApiGenericException.apiException(ex);
}
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.managed.services.test.client.exception;

public class ApiConflictException extends ApiGenericException {
public ApiConflictException(ApiUnknownException e) {
public ApiConflictException(ApiGenericException e) {
super(e);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.managed.services.test.client.exception;

public class ApiForbiddenException extends ApiGenericException {
public ApiForbiddenException(ApiUnknownException e) {
public ApiForbiddenException(ApiGenericException e) {
super(e);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ public ApiGenericException(ApiUnknownException e) {
this.id = e.getId();
}

public ApiGenericException(ApiGenericException e) {
super(e.getReason(), e);
this.responseStatusCode = e.getResponseStatusCode();
this.reason = e.getReason();
this.code = e.getCode();
this.href = e.getHref();
this.id = e.getId();
}

public ApiGenericException(
String reason,
String code,
Expand Down Expand Up @@ -60,7 +69,7 @@ public String getId() {
return id;
}

public static ApiGenericException apiException(ApiUnknownException e) {
public static ApiGenericException apiException(ApiGenericException e) {
switch (e.getResponseStatusCode()) {
case HttpURLConnection.HTTP_NOT_FOUND:
return new ApiNotFoundException(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.managed.services.test.client.exception;

public class ApiLockedException extends ApiGenericException {
public ApiLockedException(ApiUnknownException e) {
public ApiLockedException(ApiGenericException e) {
super(e);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.managed.services.test.client.exception;

public class ApiNotFoundException extends ApiGenericException {
public ApiNotFoundException(ApiUnknownException e) {
public ApiNotFoundException(ApiGenericException e) {
super(e);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.managed.services.test.client.exception;

public class ApiToManyRequestsException extends ApiGenericException {
public ApiToManyRequestsException(ApiUnknownException e) {
public ApiToManyRequestsException(ApiGenericException e) {
super(e);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.managed.services.test.client.exception;

public class ApiUnauthorizedException extends ApiGenericException {
public ApiUnauthorizedException(ApiUnknownException e) {
public ApiUnauthorizedException(ApiGenericException e) {
super(e);
}
}

0 comments on commit 7305c67

Please sign in to comment.