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>
Этот коммит содержится в:
Rodrigo Villablanca
2020-06-02 12:28:29 -04:00
коммит произвёл GitHub
родитель 60cc775cf6
Коммит 85a69d6112
16 изменённых файлов: 112 добавлений и 50 удалений

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

@@ -4,6 +4,7 @@
package app
import (
"errors"
"io"
"io/ioutil"
"net/http"
@@ -344,7 +345,7 @@ func (a *App) tryExecuteCustomCommand(args *model.CommandArgs, trigger string, m
chanChan := make(chan store.StoreResult, 1)
go func() {
channel, err := a.Srv().Store.Channel().Get(args.ChannelId, true)
chanChan <- store.StoreResult{Data: channel, Err: err}
chanChan <- store.StoreResult{Data: channel, NErr: err}
close(chanChan)
}()
@@ -380,8 +381,14 @@ func (a *App) tryExecuteCustomCommand(args *model.CommandArgs, trigger string, m
user := ur.Data.(*model.User)
cr := <-chanChan
if cr.Err != nil {
return nil, nil, cr.Err
if cr.NErr != nil {
var nfErr *store.ErrNotFound
switch {
case errors.As(cr.NErr, &nfErr):
return nil, nil, model.NewAppError("tryExecuteCustomCommand", "app.channel.get.existing.app_error", nil, nfErr.Error(), http.StatusNotFound)
default:
return nil, nil, model.NewAppError("tryExecuteCustomCommand", "app.channel.get.find.app_error", nil, cr.NErr.Error(), http.StatusInternalServerError)
}
}
channel := cr.Data.(*model.Channel)