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>
Этот коммит содержится в:
@@ -745,7 +745,7 @@ func (s SqlChannelStore) updateChannelT(transaction *sqlxTxWrapper, channel *mod
|
||||
WHERE Id=:Id`, channel)
|
||||
if err != nil {
|
||||
if IsUniqueConstraintError(err, []string{"Name", "channels_name_teamid_key"}) {
|
||||
return nil, store.NewErrInvalidInput("Channel", "Name", channel.Name)
|
||||
return nil, store.NewErrUniqueConstraint("Name")
|
||||
}
|
||||
return nil, errors.Wrapf(err, "failed to update channel with id=%s", channel.Id)
|
||||
}
|
||||
|
||||
@@ -364,10 +364,9 @@ func testChannelStoreUpdate(t *testing.T, rctx request.CTX, ss store.Store) {
|
||||
|
||||
// Make sure that the error correctly reports the wrong field to be Name
|
||||
// See https://mattermost.atlassian.net/browse/MM-53756
|
||||
var invalidInputErr *store.ErrInvalidInput
|
||||
require.ErrorAs(t, err, &invalidInputErr)
|
||||
require.Equal(t, invalidInputErr.Entity, "Channel")
|
||||
require.Equal(t, invalidInputErr.Field, "Name")
|
||||
var uniqueConstraintErr *store.ErrUniqueConstraint
|
||||
require.ErrorAs(t, err, &uniqueConstraintErr)
|
||||
require.Contains(t, uniqueConstraintErr.Columns, "Name")
|
||||
}
|
||||
|
||||
func testGetChannelUnread(t *testing.T, rctx request.CTX, ss store.Store) {
|
||||
|
||||
Ссылка в новой задаче
Block a user