Skip to content

Commit

Permalink
auth: specialize the "team not found" error
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Souza committed Aug 1, 2014
1 parent 61f36b0 commit 9c2ea45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions auth/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import (
)

var (
ErrInvalidTeamName = errors.New("Invalid team name")
ErrTeamAlreadyExists = errors.New("Team already exists")
ErrInvalidTeamName = errors.New("invalid team name")
ErrTeamAlreadyExists = errors.New("team already exists")
ErrTeamNotFound = errors.New("team not found")

teamNameRegexp = regexp.MustCompile(`^[a-zA-Z][-@_.+\w\s]+$`)
)
Expand Down Expand Up @@ -118,6 +119,9 @@ func GetTeam(name string) (*Team, error) {
}
err = conn.Teams().FindId(name).One(&t)
if err != nil {
if err == mgo.ErrNotFound {
err = ErrTeamNotFound
}
return nil, err
}
return &t, nil
Expand Down
2 changes: 1 addition & 1 deletion auth/team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,6 @@ func (s *S) TestGetTeam(c *gocheck.C) {
c.Assert(t.Name, gocheck.Equals, team.Name)
c.Assert(t.Users, gocheck.HasLen, 0)
t, err = GetTeam("wat")
c.Assert(err, gocheck.NotNil)
c.Assert(err, gocheck.Equals, ErrTeamNotFound)
c.Assert(t, gocheck.IsNil)
}

0 comments on commit 9c2ea45

Please sign in to comment.