lib/xeroizer/http.rb in xeroizer-2.16.4 vs lib/xeroizer/http.rb in xeroizer-2.16.5

- old
+ new

@@ -119,10 +119,15 @@ when 503 handle_oauth_error!(response) else handle_unknown_response_error!(response) end + rescue Xeroizer::OAuth::NonceUsed => exception + raise if attempts > nonce_used_max_attempts + logger.info("Nonce used: " + exception.to_s) if self.logger + sleep_for(1) + retry rescue Xeroizer::OAuth::RateLimitExceeded if self.rate_limit_sleep raise if attempts > rate_limit_max_attempts logger.info("Rate limit exceeded, retrying") if self.logger sleep_for(self.rate_limit_sleep) @@ -155,9 +160,10 @@ case (problem) when "token_expired" then raise OAuth::TokenExpired.new(description) when "token_rejected" then raise OAuth::TokenInvalid.new(description) when "rate limit exceeded" then raise OAuth::RateLimitExceeded.new(description) when "consumer_key_unknown" then raise OAuth::ConsumerKeyUnknown.new(description) + when "nonce_used" then raise OAuth::NonceUsed.new(description) else raise OAuth::UnknownError.new(problem + ':' + description) end else raise OAuth::UnknownError.new("Xero API may be down or the way OAuth errors are provided by Xero may have changed.") end