diff options
author | George Goldberg <george@gberg.me> | 2017-09-01 14:58:43 +0100 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-09-01 09:58:43 -0400 |
commit | 75c63344def7a108f1257b99e0342330da882a38 (patch) | |
tree | a5090e735eacf2d4dea4877a3b84e1f276e1f66b /api/channel.go | |
parent | 718da3593b6feb1c3546b1e17c30c22990157ed5 (diff) | |
download | chat-75c63344def7a108f1257b99e0342330da882a38.tar.gz chat-75c63344def7a108f1257b99e0342330da882a38.tar.bz2 chat-75c63344def7a108f1257b99e0342330da882a38.zip |
Api: NewLocAppError -> NewAppError (#7280)
Diffstat (limited to 'api/channel.go')
-rw-r--r-- | api/channel.go | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/api/channel.go b/api/channel.go index 0d2df7c5d..360d69249 100644 --- a/api/channel.go +++ b/api/channel.go @@ -172,15 +172,13 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) { } if oldChannel.DeleteAt > 0 { - c.Err = model.NewLocAppError("updateChannel", "api.channel.update_channel.deleted.app_error", nil, "") - c.Err.StatusCode = http.StatusBadRequest + c.Err = model.NewAppError("updateChannel", "api.channel.update_channel.deleted.app_error", nil, "", http.StatusBadRequest) return } if oldChannel.Name == model.DEFAULT_CHANNEL { if (len(channel.Name) > 0 && channel.Name != oldChannel.Name) || (len(channel.Type) > 0 && channel.Type != oldChannel.Type) { - c.Err = model.NewLocAppError("updateChannel", "api.channel.update_channel.tried.app_error", map[string]interface{}{"Channel": model.DEFAULT_CHANNEL}, "") - c.Err.StatusCode = http.StatusBadRequest + c.Err = model.NewAppError("updateChannel", "api.channel.update_channel.tried.app_error", map[string]interface{}{"Channel": model.DEFAULT_CHANNEL}, "", http.StatusBadRequest) return } } @@ -311,8 +309,7 @@ func updateChannelPurpose(c *Context, w http.ResponseWriter, r *http.Request) { func getChannels(c *Context, w http.ResponseWriter, r *http.Request) { if c.TeamId == "" { - c.Err = model.NewLocAppError("", "api.context.missing_teamid.app_error", nil, "TeamIdRequired") - c.Err.StatusCode = http.StatusBadRequest + c.Err = model.NewAppError("", "api.context.missing_teamid.app_error", nil, "TeamIdRequired", http.StatusBadRequest) return } // user is already in the team @@ -373,7 +370,7 @@ func getChannelCounts(c *Context, w http.ResponseWriter, r *http.Request) { // user is already in the team if counts, err := app.GetChannelCounts(c.TeamId, c.Session.UserId); err != nil { - c.Err = model.NewLocAppError("getChannelCounts", "api.channel.get_channel_counts.app_error", nil, err.Message) + c.Err = model.NewAppError("getChannelCounts", "api.channel.get_channel_counts.app_error", nil, err.Message, http.StatusInternalServerError) return } else if HandleEtag(counts.Etag(), "Get Channel Counts", w, r) { return @@ -483,7 +480,7 @@ func getChannel(c *Context, w http.ResponseWriter, r *http.Request) { } if channel.TeamId != c.TeamId && !channel.IsGroupOrDirect() { - c.Err = model.NewLocAppError("getChannel", "api.channel.get_channel.wrong_team.app_error", map[string]interface{}{"ChannelId": id, "TeamId": c.TeamId}, "") + c.Err = model.NewAppError("getChannel", "api.channel.get_channel.wrong_team.app_error", map[string]interface{}{"ChannelId": id, "TeamId": c.TeamId}, "", http.StatusBadRequest) return } @@ -519,7 +516,7 @@ func getChannelByName(c *Context, w http.ResponseWriter, r *http.Request) { } if channel.TeamId != c.TeamId && !channel.IsGroupOrDirect() { - c.Err = model.NewLocAppError("getChannel", "api.channel.get_channel.wrong_team.app_error", map[string]interface{}{"ChannelName": channelName, "TeamId": c.TeamId}, "") + c.Err = model.NewAppError("getChannel", "api.channel.get_channel.wrong_team.app_error", map[string]interface{}{"ChannelName": channelName, "TeamId": c.TeamId}, "", http.StatusBadRequest) return } @@ -544,8 +541,7 @@ func getChannelStats(c *Context, w http.ResponseWriter, r *http.Request) { } if channel.DeleteAt > 0 { - c.Err = model.NewLocAppError("getChannelStats", "api.channel.get_channel_extra_info.deleted.app_error", nil, "") - c.Err.StatusCode = http.StatusBadRequest + c.Err = model.NewAppError("getChannelStats", "api.channel.get_channel_extra_info.deleted.app_error", nil, "", http.StatusBadRequest) return } @@ -635,7 +631,7 @@ func addMember(c *Context, w http.ResponseWriter, r *http.Request) { var nUser *model.User if nUser, err = app.GetUser(userId); err != nil { - c.Err = model.NewLocAppError("addMember", "api.channel.add_member.find_user.app_error", nil, err.Error()) + c.Err = model.NewAppError("addMember", "api.channel.add_member.find_user.app_error", nil, err.Error(), http.StatusBadRequest) return } @@ -649,7 +645,7 @@ func addMember(c *Context, w http.ResponseWriter, r *http.Request) { var oUser *model.User if oUser, err = app.GetUser(c.Session.UserId); err != nil { - c.Err = model.NewLocAppError("addMember", "api.channel.add_member.user_adding.app_error", nil, err.Error()) + c.Err = model.NewAppError("addMember", "api.channel.add_member.user_adding.app_error", nil, err.Error(), http.StatusInternalServerError) return } |