-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Improve org error handling #2117
Conversation
8fc5644
to
8a97c00
Compare
Return new error type Use good error check Use new method to check error Update tests
8a97c00
to
0d24812
Compare
This is ok for review |
LGTM |
routers/api/v1/api.go
Outdated
if err != nil { | ||
if models.IsErrUserNotExist(err) { | ||
if models.IsErrOrgNotExist(err) { | ||
ctx.Status(404) | ||
} else { | ||
ctx.Error(500, "GetUserByName", err) |
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.
Please also fix 500 error name
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.
Good catch
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.
Done
LGTM |
And enforcement that :orgname is a org by using GetOrgByName inplace of GetUserByName and specific error check (GetOrgByName return ErrOrgNotExist not IsErrUserNotExist ) like it was done in CreateOrgRepo.
Before this PR we could use username as orgname.
This could also be done for enforcement of team in a other PR.