mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 13:41:47 +00:00
rpcclient: extract more detailed server-side on WS connection problem
If available. Fixes #2818.
This commit is contained in:
parent
ab0b23625b
commit
fb09670fd1
1 changed files with 9 additions and 0 deletions
|
@ -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{
|
||||||
|
|
Loading…
Reference in a new issue