More robust team exists api endpoint (#12130)

* More robust team exists api endpoint

* Making the code more concise

* Better handling of errors on GetTeamByName
Этот коммит содержится в:
Jesús Espino
2019-09-30 21:39:21 +02:00
коммит произвёл GitHub
родитель 89b7b2d99b
Коммит 8cea561ba6
5 изменённых файлов: 115 добавлений и 27 удалений

Просмотреть файл

@@ -285,6 +285,9 @@ func (s SqlTeamStore) GetByName(name string) (*model.Team, *model.AppError) {
err := s.GetReplica().SelectOne(&team, "SELECT * FROM Teams WHERE Name = :Name", map[string]interface{}{"Name": name})
if err != nil {
if err == sql.ErrNoRows {
return nil, model.NewAppError("SqlTeamStore.GetByName", "store.sql_team.get_by_name.missing.app_error", nil, "name="+name+","+err.Error(), http.StatusNotFound)
}
return nil, model.NewAppError("SqlTeamStore.GetByName", "store.sql_team.get_by_name.app_error", nil, "name="+name+", "+err.Error(), http.StatusInternalServerError)
}
return &team, nil