-
Notifications
You must be signed in to change notification settings - Fork 228
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
Fixes #421