-
Notifications
You must be signed in to change notification settings - Fork 225
Using specific error classes #138
Copy link
Copy link
Open
Labels
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
endIt 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
endReactions are currently unavailable