googleads / googleads/google-api-ads-ruby
Using specific error classes
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Ruby
- Stars
- 303
- Forks
- 221
- PR merge metrics
- No merged PRs in 30d
Description
It would be nice if this library supported exeception classes for the types of exceptions that could be received. Right now, in order to catch a specific error, I end up doing something like this
def invite_customer_to_mcc(customer)
mcc_service.mutate_link(link_operations(customer))
rescue AdwordsApi::Errors::ApiException => e
filter_permissable_errors(e, customer: customer)
end
def filter_permissable_errors(e, customer:)
permissible_reasons = %w[ALREADY_MANAGED_BY_THIS_MANAGER
ALREADY_INVITED_BY_THIS_MANAGER
TOO_MANY_INVITES]
impermissible_errors = e.errors.reject do |err|
permissible_reasons.include?(err[:reason])
end
throw e unless impermissible_errors.empty?
log_permissible_errors(customer, e)
true
end
It would be nice to just (or something similiar):
def invite_customer_to_mcc(customer)
tries = 2
begin
mcc_service.mutate_link(link_operations(customer))
rescue AdwordsApi::Errors::AlreadyManagedByThisCustomer => e
filter_permissable_errors(e, customer: customer)
end
end
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with AdwordsApi::Errors::ApiException and the rescue logic shown in the issue, then trace how API error reasons are represented and raised. Done means callers can rescue distinct exception classes for specific error reasons instead of filtering e.errors manually.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100