From d2e7389fc1c1b2fdf72cfa052c4e78a31f1cab0f Mon Sep 17 00:00:00 2001 From: Hanno Hecker Date: Mon, 23 May 2016 11:18:59 +0200 Subject: [PATCH] add Message field for "custom" errors See https://developer.github.com/v3/#client-errors Fixes #359. Change-Id: I9be617cb55e304f8f91675ce46f0726f548b742e --- github/github.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/github/github.go b/github/github.go index 756a484..8639db2 100644 --- a/github/github.go +++ b/github/github.go @@ -438,6 +438,10 @@ type ErrorResponse struct { Reason string `json:"reason,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` } `json:"block,omitempty"` + // Most errors will also include a documentation_url field pointing + // to some content that might help you resolve the error, see + // https://developer.github.com/v3/#client-errors + DocumentationURL string `json:"documentation_url,omitempty"` } func (r *ErrorResponse) Error() string { @@ -493,6 +497,9 @@ These are the possible validation error codes: the formatting of a field is invalid already_exists: another resource has the same valid as this field + custom: + some resources return this (e.g. github.User.CreateKey()), additional + information is set in the Message field of the Error GitHub API docs: http://developer.github.com/v3/#client-errors */ @@ -500,6 +507,7 @@ type Error struct { Resource string `json:"resource"` // resource on which the error occurred Field string `json:"field"` // field on which the error occurred Code string `json:"code"` // validation error code + Message string `json:"message"` // Message describing the error. Errors with Code == "custom" will always have this set. } func (e *Error) Error() string {