From 5c449f42027d32916de9f6eae132a9d08d63c037 Mon Sep 17 00:00:00 2001 From: Rodrigo Villablanca Date: Tue, 22 Sep 2020 21:51:52 -0300 Subject: [PATCH] Fix incorrect error handling (#15502) --- app/channel.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/channel.go b/app/channel.go index c3ad8a6798..14dc34cecc 100644 --- a/app/channel.go +++ b/app/channel.go @@ -1980,19 +1980,19 @@ func (a *App) LeaveChannel(channelId string, userId string) *model.AppError { }() cresult := <-sc - if cresult.Err != nil { - return cresult.Err - } - uresult := <-uc - if uresult.NErr != nil { + if cresult.NErr != nil { var nfErr *store.ErrNotFound switch { - case errors.As(uresult.NErr, &nfErr): + case errors.As(cresult.NErr, &nfErr): return model.NewAppError("LeaveChannel", "app.channel.get.existing.app_error", nil, nfErr.Error(), http.StatusNotFound) default: - return model.NewAppError("LeaveChannel", "app.channel.get.find.app_error", nil, uresult.NErr.Error(), http.StatusInternalServerError) + return model.NewAppError("LeaveChannel", "app.channel.get.find.app_error", nil, cresult.NErr.Error(), http.StatusInternalServerError) } } + uresult := <-uc + if uresult.Err != nil { + return uresult.Err + } ccresult := <-mcc if ccresult.NErr != nil { return model.NewAppError("LeaveChannel", "app.channel.get_member_count.app_error", nil, ccresult.NErr.Error(), http.StatusInternalServerError)