Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose errors field in googleapi.Error #19

Closed
gmlewis opened this issue Apr 1, 2015 · 3 comments
Closed

Expose errors field in googleapi.Error #19

gmlewis opened this issue Apr 1, 2015 · 3 comments
Assignees
Labels
imported priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@gmlewis
Copy link
Contributor

gmlewis commented Apr 1, 2015

agoode@google.com on 28 Nov 2012 at 3:22:

The Error type of googleapi only exposes code and message. But the errors field 
is needed in order to get the reason so that the recommended exponential 
backoff can be implemented:

https://developers.google.com/drive/handle-errors#implementing_exponential_backo
ff
@gmlewis gmlewis added priority: p2 Moderately-important priority. Fix may not be included in next release. imported type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Apr 1, 2015
@gmlewis
Copy link
Contributor Author

gmlewis commented Apr 1, 2015

agoode@google.com on 5 Dec 2012 at 5:14:

# HG changeset patch
# User Adam Goode <agoode@google.com>
# Date 1354684473 18000
# Node ID 2ad2fa6fd4f37ea3c84ef5b12362aec029858b7c
# Parent  4e26f8e050b6aa8abc9a417c1aac886670412cb5
Expose errors field in googleapi.Error

diff -r 4e26f8e050b6 -r 2ad2fa6fd4f3 googleapi/googleapi.go
--- a/googleapi/googleapi.go    Wed Dec 05 00:10:56 2012 -0500
+++ b/googleapi/googleapi.go    Wed Dec 05 00:14:33 2012 -0500
@@ -28,11 +28,22 @@
    ContentType() string
 }

-const Version = "0.5"
+const Version = "0.6"

 type Error struct {
-   Code    int    `json:"code"`
-   Message string `json:"message"`
+   Code    int           `json:"code"`
+   Message string        `json:"message"`
+   Errors  []NestedError `json:"errors"`
+}
+
+type NestedError struct {
+   Domain       string `json:"domain"`
+   Reason       string `json:"reason"`
+   Message      string `json:"message"`
+   Location     string `json:"location"`
+   LocationType string `json:"locationType"`
+   ExtendedHelp string `json:"extendedHelp"`
+   SendReport   string `json:"sendReport"`
 }

 func (e *Error) Error() string {

@gmlewis
Copy link
Contributor Author

gmlewis commented Apr 7, 2015

Successfully auto-migrated from code.google.com:
https://code.google.com/p/google-api-go-client/issues/detail?id=19

@gmlewis
Copy link
Contributor Author

gmlewis commented Apr 7, 2015

This issue was addressed by:
7278d07
Now clients can fully parse error messages returned by servers and retrieve the fields they are interested in.
Closing.

@gmlewis gmlewis closed this as completed Apr 7, 2015
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants