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 authored and Daniel Azuma committed 2018-12-04 12:06:24 -08:00
1 parent df67c60740
commit d6247a7794
1 file changed
+9
+9
View File
@@ -41,6 +41,15 @@ module Google
super
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
# An error which is raised when there is an unexpected response or other