diff options
Diffstat (limited to 'store/sql_command_store.go')
-rw-r--r-- | store/sql_command_store.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/store/sql_command_store.go b/store/sql_command_store.go index a767e764d..443e3ba63 100644 --- a/store/sql_command_store.go +++ b/store/sql_command_store.go @@ -4,6 +4,8 @@ package store import ( + "net/http" + "github.com/mattermost/mattermost-server/model" ) @@ -48,7 +50,7 @@ func (s SqlCommandStore) Save(command *model.Command) StoreChannel { result := StoreResult{} if len(command.Id) > 0 { - result.Err = model.NewLocAppError("SqlCommandStore.Save", "store.sql_command.save.saving_overwrite.app_error", nil, "id="+command.Id) + result.Err = model.NewAppError("SqlCommandStore.Save", "store.sql_command.save.saving_overwrite.app_error", nil, "id="+command.Id, http.StatusBadRequest) storeChannel <- result close(storeChannel) return @@ -62,7 +64,7 @@ func (s SqlCommandStore) Save(command *model.Command) StoreChannel { } if err := s.GetMaster().Insert(command); err != nil { - result.Err = model.NewLocAppError("SqlCommandStore.Save", "store.sql_command.save.saving.app_error", nil, "id="+command.Id+", "+err.Error()) + result.Err = model.NewAppError("SqlCommandStore.Save", "store.sql_command.save.saving.app_error", nil, "id="+command.Id+", "+err.Error(), http.StatusInternalServerError) } else { result.Data = command } @@ -83,7 +85,7 @@ func (s SqlCommandStore) Get(id string) StoreChannel { var command model.Command if err := s.GetReplica().SelectOne(&command, "SELECT * FROM Commands WHERE Id = :Id AND DeleteAt = 0", map[string]interface{}{"Id": id}); err != nil { - result.Err = model.NewLocAppError("SqlCommandStore.Get", "store.sql_command.save.get.app_error", nil, "id="+id+", err="+err.Error()) + result.Err = model.NewAppError("SqlCommandStore.Get", "store.sql_command.save.get.app_error", nil, "id="+id+", err="+err.Error(), http.StatusInternalServerError) } result.Data = &command @@ -104,7 +106,7 @@ func (s SqlCommandStore) GetByTeam(teamId string) StoreChannel { var commands []*model.Command if _, err := s.GetReplica().Select(&commands, "SELECT * FROM Commands WHERE TeamId = :TeamId AND DeleteAt = 0", map[string]interface{}{"TeamId": teamId}); err != nil { - result.Err = model.NewLocAppError("SqlCommandStore.GetByTeam", "store.sql_command.save.get_team.app_error", nil, "teamId="+teamId+", err="+err.Error()) + result.Err = model.NewAppError("SqlCommandStore.GetByTeam", "store.sql_command.save.get_team.app_error", nil, "teamId="+teamId+", err="+err.Error(), http.StatusInternalServerError) } result.Data = commands @@ -124,7 +126,7 @@ func (s SqlCommandStore) Delete(commandId string, time int64) StoreChannel { _, err := s.GetMaster().Exec("Update Commands SET DeleteAt = :DeleteAt, UpdateAt = :UpdateAt WHERE Id = :Id", map[string]interface{}{"DeleteAt": time, "UpdateAt": time, "Id": commandId}) if err != nil { - result.Err = model.NewLocAppError("SqlCommandStore.Delete", "store.sql_command.save.delete.app_error", nil, "id="+commandId+", err="+err.Error()) + result.Err = model.NewAppError("SqlCommandStore.Delete", "store.sql_command.save.delete.app_error", nil, "id="+commandId+", err="+err.Error(), http.StatusInternalServerError) } storeChannel <- result @@ -142,7 +144,7 @@ func (s SqlCommandStore) PermanentDeleteByTeam(teamId string) StoreChannel { _, err := s.GetMaster().Exec("DELETE FROM Commands WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId}) if err != nil { - result.Err = model.NewLocAppError("SqlCommandStore.DeleteByTeam", "store.sql_command.save.delete_perm.app_error", nil, "id="+teamId+", err="+err.Error()) + result.Err = model.NewAppError("SqlCommandStore.DeleteByTeam", "store.sql_command.save.delete_perm.app_error", nil, "id="+teamId+", err="+err.Error(), http.StatusInternalServerError) } storeChannel <- result @@ -160,7 +162,7 @@ func (s SqlCommandStore) PermanentDeleteByUser(userId string) StoreChannel { _, err := s.GetMaster().Exec("DELETE FROM Commands WHERE CreatorId = :UserId", map[string]interface{}{"UserId": userId}) if err != nil { - result.Err = model.NewLocAppError("SqlCommandStore.DeleteByUser", "store.sql_command.save.delete_perm.app_error", nil, "id="+userId+", err="+err.Error()) + result.Err = model.NewAppError("SqlCommandStore.DeleteByUser", "store.sql_command.save.delete_perm.app_error", nil, "id="+userId+", err="+err.Error(), http.StatusInternalServerError) } storeChannel <- result @@ -179,7 +181,7 @@ func (s SqlCommandStore) Update(cmd *model.Command) StoreChannel { cmd.UpdateAt = model.GetMillis() if _, err := s.GetMaster().Update(cmd); err != nil { - result.Err = model.NewLocAppError("SqlCommandStore.Update", "store.sql_command.save.update.app_error", nil, "id="+cmd.Id+", "+err.Error()) + result.Err = model.NewAppError("SqlCommandStore.Update", "store.sql_command.save.update.app_error", nil, "id="+cmd.Id+", "+err.Error(), http.StatusInternalServerError) } else { result.Data = cmd } @@ -210,7 +212,7 @@ func (s SqlCommandStore) AnalyticsCommandCount(teamId string) StoreChannel { } if c, err := s.GetReplica().SelectInt(query, map[string]interface{}{"TeamId": teamId}); err != nil { - result.Err = model.NewLocAppError("SqlCommandStore.AnalyticsCommandCount", "store.sql_command.analytics_command_count.app_error", nil, err.Error()) + result.Err = model.NewAppError("SqlCommandStore.AnalyticsCommandCount", "store.sql_command.analytics_command_count.app_error", nil, err.Error(), http.StatusInternalServerError) } else { result.Data = c } |