From 75c63344def7a108f1257b99e0342330da882a38 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Fri, 1 Sep 2017 14:58:43 +0100 Subject: Api: NewLocAppError -> NewAppError (#7280) --- api/channel.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'api/channel.go') 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 } -- cgit v1.2.3-1-g7c22