From 1cea86609bd580150798cf067a504f8328a547aa Mon Sep 17 00:00:00 2001 From: Sudipta Chatterjee Date: Fri, 10 Apr 2015 16:12:37 -0700 Subject: [PATCH] Updating success logic Updating the definition of SUCCESS response code to be 200 OK or 201 Continue. Error is anything that isn't success. This helps flag conditions like an unsuccessful update (return code 304) which the library would have flagged as success earlier --- lib/google/api_client/result.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/google/api_client/result.rb b/lib/google/api_client/result.rb index c48bec04a..090f22947 100644 --- a/lib/google/api_client/result.rb +++ b/lib/google/api_client/result.rb @@ -79,13 +79,13 @@ module Google end ## - # Check if request failed + # Check if request failed - which is anything other than 200/201 OK # # @!attribute [r] error? # @return [TrueClass, FalseClass] # true if result of operation is an error def error? - return self.response.status >= 400 + return !self.success? end ## @@ -95,7 +95,11 @@ module Google # @return [TrueClass, FalseClass] # true if result of operation was successful def success? - return !self.error? + if self.response.status == 200 || self.response.status == 201 + return true + else + return false + end end ##