[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
@@ -59,13 +59,13 @@ type WebSocketClient struct {
|
||||
|
||||
// NewWebSocketClient constructs a new WebSocket client with convenience
|
||||
// methods for talking to the server.
|
||||
func NewWebSocketClient(url, authToken string) (*WebSocketClient, *AppError) {
|
||||
func NewWebSocketClient(url, authToken string) (*WebSocketClient, error) {
|
||||
return NewWebSocketClientWithDialer(websocket.DefaultDialer, url, authToken)
|
||||
}
|
||||
|
||||
// NewWebSocketClientWithDialer constructs a new WebSocket client with convenience
|
||||
// methods for talking to the server using a custom dialer.
|
||||
func NewWebSocketClientWithDialer(dialer *websocket.Dialer, url, authToken string) (*WebSocketClient, *AppError) {
|
||||
func NewWebSocketClientWithDialer(dialer *websocket.Dialer, url, authToken string) (*WebSocketClient, error) {
|
||||
conn, _, err := dialer.Dial(url+ApiUrlSuffix+"/websocket", nil)
|
||||
if err != nil {
|
||||
return nil, NewAppError("NewWebSocketClient", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -97,13 +97,13 @@ func NewWebSocketClientWithDialer(dialer *websocket.Dialer, url, authToken strin
|
||||
|
||||
// NewWebSocketClient4 constructs a new WebSocket client with convenience
|
||||
// methods for talking to the server. Uses the v4 endpoint.
|
||||
func NewWebSocketClient4(url, authToken string) (*WebSocketClient, *AppError) {
|
||||
func NewWebSocketClient4(url, authToken string) (*WebSocketClient, error) {
|
||||
return NewWebSocketClient4WithDialer(websocket.DefaultDialer, url, authToken)
|
||||
}
|
||||
|
||||
// NewWebSocketClient4WithDialer constructs a new WebSocket client with convenience
|
||||
// methods for talking to the server using a custom dialer. Uses the v4 endpoint.
|
||||
func NewWebSocketClient4WithDialer(dialer *websocket.Dialer, url, authToken string) (*WebSocketClient, *AppError) {
|
||||
func NewWebSocketClient4WithDialer(dialer *websocket.Dialer, url, authToken string) (*WebSocketClient, error) {
|
||||
return NewWebSocketClientWithDialer(dialer, url, authToken)
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user