Skip to content
New issue

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

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

Already on GitHub? # to your account

Improvements on API error, swagger and status code #428

Merged
merged 6 commits into from
Dec 13, 2016

Conversation

pedronasser
Copy link
Contributor

@pedronasser pedronasser commented Dec 13, 2016

Fixes #421

Copy link
Contributor

@ucirello ucirello left a comment

Choose a reason for hiding this comment

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

This looks nice, however I am pretty confident that it is not fixing the proposed bug, or the bug was generated with a very old version of fn.

The reason is that in the issue it states:

{"error":{"message":"Could not create route"}}

Whereas, when you look at routes_update you don't see the constant ErrRoutesCreate anywhere.

How did you reproduce the bug before fixing it?

@@ -194,7 +194,7 @@ func TestRouteUpdate(t *testing.T) {
{&datastore.Mock{}, "/v1/apps/a/routes/myroute/do", ``, http.StatusBadRequest, models.ErrInvalidJSON},
{&datastore.Mock{}, "/v1/apps/a/routes/myroute/do", `{}`, http.StatusBadRequest, models.ErrRoutesMissingNew},

// success
// successTe
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo?

@@ -52,7 +52,13 @@ func (s *Server) handleRouteUpdate(c *gin.Context) {

route, err := s.Datastore.UpdateRoute(ctx, wroute.Route)
if err != nil {
log.WithError(err).Debug(models.ErrRoutesUpdate)
if err == models.ErrRoutesNotFound {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps:

if err == models.ErrRoutesNotFound {
...
} else if err != nil {
...
}

So to avoid if-within-if situation?

@pedronasser pedronasser merged commit 32de7d5 into master Dec 13, 2016
@pedronasser pedronasser deleted the improve-api-error-messages branch December 13, 2016 21:18
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants