[MM-37557] Move error out of client4 response (#18101)
* Return an error seperately from Response * Remove BuildErrorResponse * Drop Response.Error from model/client4.go * Migrate require.Nil checks * Migrate require.NotNil checks * More manual fixes * Move error check out of CheckOKStatus and CheckCreatedStatus * Move error check out of CheckForbiddenStatus * Move error check out of CheckUnauthorizedStatus * Move error check out of CheckNotFoundStatus * Move error check out of CheckBadRequestStatus * Move error check out of CheckNotImplementedStatus and CheckRequestEntityTooLargeStatus * Move error check out of CheckInternalErrorStatus * Move error check out of CheckServiceUnavailableStatus * Remove error check from checkHTTPStatus * Remove remaining references to Response.Error * Check previously unchecked errors * Manually fix compile and linter errors * Return error in CreateWebSocket methods * Return error instead of *AppError in DoApi methods * Manually fix bad replacments * Conistently return Response and error * Use err instead of seperate bool return value to indicate success * Reduce ussage of model.AppError in web/oauth_test.go * Remove client4.Must * Check error in buf.ReadFrom * Fix failing tests
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
96593580ae
Коммит
a8ca5c423f
@@ -107,9 +107,16 @@ func manualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
|
||||
Nickname: username[0],
|
||||
Password: slashcommands.UserPassword}
|
||||
|
||||
user, resp := client.CreateUser(user)
|
||||
if resp.Error != nil {
|
||||
c.Err = resp.Error
|
||||
user, _, err = client.CreateUser(user)
|
||||
if err != nil {
|
||||
var appErr *model.AppError
|
||||
ok = errors.As(err, &appErr)
|
||||
if ok {
|
||||
c.Err = appErr
|
||||
} else {
|
||||
c.Err = model.NewAppError("manualTest", "app.user.save.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -119,9 +126,15 @@ func manualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
|
||||
userID = user.Id
|
||||
|
||||
// Login as user to generate auth token
|
||||
_, resp = client.LoginById(user.Id, slashcommands.UserPassword)
|
||||
if resp.Error != nil {
|
||||
c.Err = resp.Error
|
||||
_, _, err = client.LoginById(user.Id, slashcommands.UserPassword)
|
||||
if err != nil {
|
||||
var appErr *model.AppError
|
||||
ok = errors.As(err, &appErr)
|
||||
if ok {
|
||||
c.Err = appErr
|
||||
} else {
|
||||
c.Err = model.NewAppError("manualTest", "api.user.login.bot_login_forbidden.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user