mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 23:42:23 +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.
|
||||
}
|
||||
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
|
||||
}
|
||||
wsc := &WSClient{
|
||||
|
|
Loading…
Reference in a new issue