Add custom inspect to Google::Apis:Error (#729)

Add the status_code, header, and body values to inspect when present.
These values can help users understand why they are getting errors,
but many users don't know to look for them.
Adding the values to inspect should help discoverability.
This commit is contained in:
Mike Moore 2018-12-04 13:06:24 -07:00 committed by Daniel Azuma
parent df67c60740
commit d6247a7794
1 changed files with 9 additions and 0 deletions

View File

@ -41,6 +41,15 @@ module Google
super super
end end
end end
def inspect
extra = ""
extra << " status_code: #{status_code.inspect}" unless status_code.nil?
extra << " header: #{header.inspect}" unless header.nil?
extra << " body: #{body.inspect}" unless body.nil?
"#<#{self.class.name}: #{message}#{extra}>"
end
end end
# An error which is raised when there is an unexpected response or other # An error which is raised when there is an unexpected response or other