(HttpResponse<String> response)
| 69 | } |
| 70 | |
| 71 | private static void throwParsedVaasError(HttpResponse<String> response) throws VaasAuthenticationException, VaasClientException, VaasServerException { |
| 72 | try { |
| 73 | var problemDetails = ProblemDetails.fromJson(response.body()); |
| 74 | if(problemDetails == null) { |
| 75 | throw new JsonSyntaxException("no JSON in server response"); |
| 76 | } |
| 77 | var type = problemDetails.type; |
| 78 | var detail = problemDetails.detail; |
| 79 | if (type.equals("VaasClientException")) { |
| 80 | throw new VaasClientException(detail); |
| 81 | } else if (type.equals("VaasAuthenticationException")) { |
| 82 | throw new VaasAuthenticationException(detail); |
| 83 | } |
| 84 | throw new VaasServerException(detail); |
| 85 | } catch(JsonSyntaxException e) { |
| 86 | if (response.statusCode() == 401) { |
| 87 | throw new VaasAuthenticationException( |
| 88 | "Server did not accept token from identity provider. Check if you are using the correct identity provider and credentials."); |
| 89 | } else if (response.statusCode() >= 400 && response.statusCode() < 500) { |
| 90 | throw new VaasClientException("HTTP Error: " + response.statusCode() + " for request " + response.uri()); |
| 91 | } else { |
| 92 | throw new VaasServerException("HTTP Error: " + response.statusCode() + " for request " + response.uri()); |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | private static String encodeParams(Map<String, String> params) { |
| 98 | StringBuilder encodedParams = new StringBuilder(); |
no test coverage detected