Skip to content

Commit

Permalink
Add suggestion about using github.com/pkg/errors for error renderers
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Kieltyka authored and Peter Kieltyka committed Mar 30, 2017
1 parent af97407 commit 2810210
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions _examples/rest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,6 @@ type ArticleResponse struct {
func NewArticleResponse(article *Article) *ArticleResponse {
resp := &ArticleResponse{Article: article}

// resp.Elapsed = 10

if resp.User == nil {
if user, _ := dbGetUser(resp.UserID); user != nil {
resp.User = NewUserPayloadResponse(user)
Expand Down Expand Up @@ -388,6 +386,11 @@ func NewArticleListResponse(articles []*Article) []render.Renderer {
// Error response payloads & renderers
//--

// ErrResponse renderer type for handling all sorts of errors.
//
// In the best case scenario, the excellent github.com/pkg/errors package
// helps reveal information on the error, setting it on Err, and in the Render()
// method, using it to set the application-specific error code in AppCode.
type ErrResponse struct {
Err error `json:"-"` // low-level runtime error
HTTPStatusCode int `json:"-"` // http response status code
Expand Down

0 comments on commit 2810210

Please sign in to comment.