Migrate GetChannels method from ChannelStore to return error interface (#14711)

* Migrate GetChannels method from ChannelStore to return error interface

* Fix testing

* Changed error type: ErrInvalidInput -> ErrNotFound

* Added note about error migrations

* Fix en.json

* Fix i18n

Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
Этот коммит содержится в:
Rodrigo Villablanca
2020-06-11 04:32:03 -04:00
коммит произвёл GitHub
родитель 9b0ae49b55
Коммит 41d9c673cf
10 изменённых файлов: 66 добавлений и 39 удалений

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

@@ -1551,7 +1551,18 @@ func (a *App) GetChannelByNameForTeamName(channelName, teamName string, includeD
}
func (a *App) GetChannelsForUser(teamId string, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
return a.Srv().Store.Channel().GetChannels(teamId, userId, includeDeleted)
list, err := a.Srv().Store.Channel().GetChannels(teamId, userId, includeDeleted)
if err != nil {
var nfErr *store.ErrNotFound
switch {
case errors.As(err, &nfErr):
return nil, model.NewAppError("GetChannelsForUser", "app.channel.get_channels.not_found.app_error", nil, nfErr.Error(), http.StatusNotFound)
default:
return nil, model.NewAppError("GetChannelsForUser", "app.channel.get_channels.get.app_error", nil, err.Error(), http.StatusInternalServerError)
}
}
return list, nil
}
func (a *App) GetAllChannels(page, perPage int, opts model.ChannelSearchOpts) (*model.ChannelListWithTeamData, *model.AppError) {