SDA_query: handle API failures with more grace #351
Merged
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.
Soil Data Access goes down intermittently for maintenance or due to crashes of the server. This PR adds handling to check the response content type for
SDA_query()
POST requests.Essentially, any content type other than JSON (data) or XML (error message) indicates the service is temporarily down. When the service is down it does not produce normal response that can be used by either the data or error parsing approach.
As an additional item in this PR I will develop a wrapper function that can catch errors and print an informative message for the user--there are several instances of functions that use
SDA_query()
but do not handle the possibility of try-error response--which can result in some unusual error messages in lieu of expected result. We will distinguish this "service is down" case from other possible issues (say, incorrectly formatted arguments that affect the query used)