diff --git a/src/main/java/com/twocheckout/TwocheckoutApi.java b/src/main/java/com/twocheckout/TwocheckoutApi.java index 7014a7e..5cea665 100644 --- a/src/main/java/com/twocheckout/TwocheckoutApi.java +++ b/src/main/java/com/twocheckout/TwocheckoutApi.java @@ -63,8 +63,10 @@ public static String get(String urlSuffix, HashMap 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; @@ -102,8 +104,10 @@ public static String post(String urlSuffix, HashMap 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; @@ -136,8 +140,10 @@ public static String auth(String urlSuffix, HashMap 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; @@ -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]); } } @@ -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); } }