Spring / Spring CredHub Interview questions
How is CredHubException structured?
CredHubException lives in org.springframework.credhub.core and extends Spring's RestClientResponseException (itself a HttpStatusCodeException), which means every failed CredHub call surfaces the same rich HTTP context a REST client would give you: status code, status text, response headers, and response body.
Because it's an unchecked RuntimeException in the NestedRuntimeException hierarchy, calling code isn't forced to catch it on every call; it can be handled centrally, for example in a Spring @ControllerAdvice that maps a 404 to "credential not found" and anything else to a generic failure.
Inspecting getStatusCode() or getResponseBodyAsString() on the caught exception is the normal way to figure out why a particular CredHub call failed.
More Related questions...