summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store.go
diff options
context:
space:
mode:
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r--store/sql_channel_store.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index 35322e061..c7ffddd56 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -4,11 +4,16 @@
package store
import (
+ "database/sql"
"github.com/go-gorp/gorp"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
)
+const (
+ MISSING_CHANNEL_ERROR = "store.sql_channel.get_by_name.missing.app_error"
+)
+
type SqlChannelStore struct {
*SqlStore
}
@@ -437,7 +442,11 @@ func (s SqlChannelStore) GetByName(teamId string, name string) StoreChannel {
channel := model.Channel{}
if err := s.GetReplica().SelectOne(&channel, "SELECT * FROM Channels WHERE TeamId = :TeamId AND Name= :Name AND DeleteAt = 0", map[string]interface{}{"TeamId": teamId, "Name": name}); err != nil {
- result.Err = model.NewLocAppError("SqlChannelStore.GetByName", "store.sql_channel.get_by_name.existing.app_error", nil, "teamId="+teamId+", "+"name="+name+", "+err.Error())
+ if err == sql.ErrNoRows {
+ result.Err = model.NewLocAppError("SqlChannelStore.GetByName", MISSING_CHANNEL_ERROR, nil, "teamId="+teamId+", "+"name="+name+", "+err.Error())
+ } else {
+ result.Err = model.NewLocAppError("SqlChannelStore.GetByName", "store.sql_channel.get_by_name.existing.app_error", nil, "teamId="+teamId+", "+"name="+name+", "+err.Error())
+ }
} else {
result.Data = &channel
}