client: add info from http response to client exception #2486
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When using the
HttpTransport
with the Java client, if the receiving service (Marquez or whatever) responds with a non-2xx status then anOpenLineageClientException
is thrown with a descriptive message. The consuming code may want to do something different with that exception depending on the response - e.g. we might retry the operation for a 502 but not for a 400. Currently this information has to be parsed out of the exception message.Solution
This PR adds
HttpTransportResponseException
, a subclass ofOpenLineageClientException
that includes fields for status code and body - this is what is now thrown in the event of a non-2xx response. Note that other exception-raising scenarios like timeouts and bad config will behave as previously. Also, themessage
on the exception remains the same for backwards compatibility.One-line summary:
Adds the status code and body as properties on the thrown exception when a non-success response is encountered in the HTTP transport.
Checklist
SPDX-License-Identifier: Apache-2.0
Copyright 2018-2023 contributors to the OpenLineage project