Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDA_query: handle API failures with more grace #351

Merged
merged 2 commits into from
May 31, 2024
Merged

Conversation

brownag
Copy link
Member

@brownag brownag commented May 17, 2024

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)

 - HTML or any other content type than JSON (data) or XML (error message) indicates the service is temporarily down
@dylanbeaudette
Copy link
Member

Thanks. The additional error handling will help downstream functions fail gracefully. I never expected that SDA would be "down" so frequently.

@brownag brownag marked this pull request as ready for review May 30, 2024 15:02
@brownag brownag merged commit bb54b6a into master May 31, 2024
5 checks passed
@brownag brownag deleted the sda-query-error1 branch September 17, 2024 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants