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

Exclude nil Response from response body #41

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/mock/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,17 @@ func WriteError(
) {
w.WriteHeader(httpStatus)

w.Write(MustMarshal(github.ErrorResponse{
w.Write(MustMarshal(gitHubErrorReponse{
Message: msg,
Errors: errors,
}))
}

// A struct with the fields that we need from github.ErrorResponse.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @stoneman , I'm sorry it has taken quite a while for me to get around reviewing this.

I will have a look at this later today. Thanks for contributing!

// We don't use github.ErrorResponse directly because the Response field would
// also get marshaled as null and that would override the Response that
// go-github sets before unmarshaling the response body.
type gitHubErrorReponse struct {
Message string `json:"message"` // error message
Errors []github.Error `json:"errors"` // more detail on individual errors
}