MM-57391: improve error message (#26630)
The error reporte when moving channels and failing has been improved to show that the problem was the repeated name on the team. The error message has been unified with MM-53756 Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -622,12 +622,12 @@ func (a *App) UpdateChannel(c request.CTX, channel *model.Channel) (*model.Chann
|
||||
_, err := a.Srv().Store().Channel().Update(c, channel)
|
||||
if err != nil {
|
||||
var appErr *model.AppError
|
||||
var uniqueConstraintErr *store.ErrUniqueConstraint
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &uniqueConstraintErr):
|
||||
return nil, model.NewAppError("UpdateChannel", store.ChannelExistsError, nil, "", http.StatusBadRequest).Wrap(err)
|
||||
case errors.As(err, &invErr):
|
||||
if invErr.Entity == "Channel" && invErr.Field == "Name" {
|
||||
return nil, model.NewAppError("UpdateChannel", store.ChannelExistsError, nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
return nil, model.NewAppError("UpdateChannel", "app.channel.update.bad_id", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
case errors.As(err, &appErr):
|
||||
return nil, appErr
|
||||
@@ -3149,10 +3149,13 @@ func (a *App) MoveChannel(c request.CTX, team *model.Team, channel *model.Channe
|
||||
channel.TeamId = team.Id
|
||||
if _, err := a.Srv().Store().Channel().Update(c, channel); err != nil {
|
||||
var appErr *model.AppError
|
||||
var uniqueConstraintErr *store.ErrUniqueConstraint
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &invErr):
|
||||
return model.NewAppError("MoveChannel", "app.channel.update.bad_id", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
case errors.As(err, &uniqueConstraintErr):
|
||||
return model.NewAppError("MoveChannel", store.ChannelExistsError, nil, "", http.StatusBadRequest).Wrap(err)
|
||||
case errors.As(err, &appErr):
|
||||
return appErr
|
||||
default:
|
||||
|
||||
Ссылка в новой задаче
Block a user