rpcclient: extract more detailed server-side on WS connection problem

If available. Fixes #2818.
This commit is contained in:
Roman Khimov 2022-11-23 11:25:05 +03:00
parent ab0b23625b
commit fb09670fd1

View file

@ -365,6 +365,15 @@ func NewWS(ctx context.Context, endpoint string, opts Options) (*WSClient, error
defer resp.Body.Close() // Not exactly required by websocket, but let's do this for bodyclose checker. defer resp.Body.Close() // Not exactly required by websocket, but let's do this for bodyclose checker.
} }
if err != nil { if err != nil {
if resp != nil && resp.Body != nil {
var srvErr neorpc.HeaderAndError
dec := json.NewDecoder(resp.Body)
decErr := dec.Decode(&srvErr)
if decErr == nil && srvErr.Error != nil {
err = srvErr.Error
}
}
return nil, err return nil, err
} }
wsc := &WSClient{ wsc := &WSClient{