Skip to content

Commit f76e51f

Browse files
author
Ilya Sher
committed
PkiResponse - embed error information received from server in thrown exception
1 parent 04f0ec3 commit f76e51f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • src/main/java/com/bettercloud/vault/api/pki

src/main/java/com/bettercloud/vault/api/pki/Pki.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.bettercloud.vault.rest.Rest;
99
import com.bettercloud.vault.rest.RestResponse;
1010

11+
import java.util.Arrays;
1112
import java.util.List;
1213
import java.util.stream.Collectors;
1314

@@ -455,7 +456,8 @@ public PkiResponse issue(
455456

456457
// Validate response
457458
if (restResponse.getStatus() != 200 && restResponse.getStatus() != 404) {
458-
throw new VaultException("Vault responded with HTTP status code: " + restResponse.getStatus(), restResponse.getStatus());
459+
String body = restResponse.getBody() != null ? new String(restResponse.getBody()) : "(no body)";
460+
throw new VaultException("Vault responded with HTTP status code: " + restResponse.getStatus() + " " + body, restResponse.getStatus());
459461
}
460462
return new PkiResponse(restResponse, retryCount);
461463
} catch (Exception e) {

0 commit comments

Comments
 (0)