Skip to content

Commit 517c66e

Browse files
authored
Check for nil resp before using resp.Status after DialContext error (#109)
* Includes HTTP error code when gorilla DialContext fails * Check for nil resp before using resp.Status
1 parent 41426b4 commit 517c66e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/transport/websocket_transport.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,11 @@ func NewWebsocketClientTransport(ctx context.Context, url string, config *tls.Co
186186
}
187187
conn, resp, err := dial.DialContext(ctx, url, header)
188188
if err != nil {
189-
return nil, errors.Wrapf(err, "dial websocket failed: %s", resp.Status)
189+
if resp != nil {
190+
return nil, errors.Wrapf(err, "dial websocket failed: %s", resp.Status)
191+
} else {
192+
return nil, errors.Wrap(err, "dial websocket failed")
193+
}
190194
}
191195
return NewTransport(NewWebsocketConnection(conn)), nil
192196
}

0 commit comments

Comments
 (0)