Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/main/java/com/twocheckout/TwocheckoutApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ public static String get(String urlSuffix, HashMap<String, String> args) throws
return responseBody;
}

} catch (TwocheckoutException e) {
throw e;
} catch (Exception e) {
throw new TwocheckoutException(e.getMessage());
throw new TwocheckoutException(e.getMessage(),e);
}

return mainObject;
Expand Down Expand Up @@ -102,8 +104,10 @@ public static String post(String urlSuffix, HashMap<String, String> args) throws
return responseBody;
}

} catch (TwocheckoutException e) {
throw e;
} catch (Exception e) {
throw new TwocheckoutException(e.getMessage());
throw new TwocheckoutException(e.getMessage(),e);
}

return mainObject;
Expand Down Expand Up @@ -136,8 +140,10 @@ public static String auth(String urlSuffix, HashMap<String, Object> args) throws
return responseBody;
}

} catch (TwocheckoutException e) {
throw e;
} catch (Exception e) {
throw new TwocheckoutException(e.getMessage());
throw new TwocheckoutException(e.getMessage(),e);
}

return mainObject;
Expand All @@ -157,7 +163,7 @@ private static void checkStatusCodeAdmin(HttpResponse response, String responseB
if (status.getStatusCode() != HttpStatus.SC_OK) {
Errors errors = new Gson().fromJson(responseBody, Errors.class);
Error[] error = errors.getErrors();
throw new TwocheckoutException(error[0].getMessage());
throw new TwocheckoutException(error[0].getMessage(), error[0]);
}
}

Expand All @@ -166,7 +172,7 @@ private static void checkStatusCodeAuth(HttpResponse response, String responseBo
if (status.getStatusCode() != HttpStatus.SC_OK && status.getStatusCode() != HttpStatus.SC_ACCEPTED ) {
AuthExceptions exceptions = new Gson().fromJson(responseBody, AuthExceptions.class);
AuthException exception = exceptions.getAuthExceptions();
throw new TwocheckoutException(exception.getMessage());
throw new TwocheckoutException(exception.getMessage(),exception);
}
}

Expand Down