Migrate Get/GetFromMaster methods from ChannelStore to return error interface (#14688)
* Advances * Migration finished * Rename err to normalized error * fix imports * Renamed key * Renamed key * Suggestions * Fix i18n * Fix tests Co-authored-by: Jesús Espino <jespinog@gmail.com> Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
60cc775cf6
Коммит
85a69d6112
@@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
@@ -480,7 +481,13 @@ func (s *SqlGroupStore) CreateGroupSyncable(groupSyncable *model.GroupSyncable)
|
||||
insertErr = s.GetMaster().Insert(groupSyncableToGroupTeam(groupSyncable))
|
||||
case model.GroupSyncableTypeChannel:
|
||||
if _, err := s.Channel().Get(groupSyncable.SyncableId, false); err != nil {
|
||||
return nil, err
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(err, &nfErr):
|
||||
return nil, model.NewAppError("CreateGroupSyncable", "store.sql_channel.get.existing.app_error", nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("CreateGroupSyncable", "store.sql_channel.get.find.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
insertErr = s.GetMaster().Insert(groupSyncableToGroupChannel(groupSyncable))
|
||||
|
||||
Ссылка в новой задаче
Block a user