Idiom for partial failures

David Wihl davidwihl at gmail.com
Thu Feb 20 12:30:06 EST 2020



(first post)

I'm working on the Python client library [0]for the Google Ads API [1]. In some cases, we can start a request with a partial failure [2] flag = True. This means that the request may contain say 1000 operations. If any of the operations fail, the request will return with a success status without an exception. Then the developer has to iterate through the list of operation return statuses to determine which specific ones failed (example [3]).

I believe that it would be more idiomatic in Python (and other languages like Ruby) to throw an exception when one of these partial errors occur. That way there would be the same control flow if a major or minor error occurred. 

The team is asking me for other examples or justification of this being idiomatic of Python. Can you recommend any examples or related best practices?

[0] https://github.com/googleads/google-ads-python

[1] https://developers.google.com/google-ads/api/docs/start

[2] https://developers.google.com/google-ads/api/docs/best-practices/partial-failures

[3] https://github.com/googleads/google-ads-python/blob/master/examples/error_handling/handle_partial_failure.py

Thanks!
-David


More information about the Python-list mailing list