Introduce APIError type and make ErrorEvent.Err public
This makes it a little bit easier to act on API errors that happen while streaming.
This commit is contained in:
parent
9faaa4f0dc
commit
972ffb4771
6 changed files with 49 additions and 24 deletions
|
@ -88,7 +88,7 @@ func (c *WSClient) streamingWS(ctx context.Context, stream, tag string) (chan Ev
|
|||
func (c *WSClient) handleWS(ctx context.Context, rawurl string, q chan Event) error {
|
||||
conn, err := c.dialRedirect(rawurl)
|
||||
if err != nil {
|
||||
q <- &ErrorEvent{err: err}
|
||||
q <- &ErrorEvent{Err: err}
|
||||
|
||||
// End.
|
||||
return err
|
||||
|
@ -103,7 +103,7 @@ func (c *WSClient) handleWS(ctx context.Context, rawurl string, q chan Event) er
|
|||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
q <- &ErrorEvent{err: ctx.Err()}
|
||||
q <- &ErrorEvent{Err: ctx.Err()}
|
||||
|
||||
// End.
|
||||
return ctx.Err()
|
||||
|
@ -113,7 +113,7 @@ func (c *WSClient) handleWS(ctx context.Context, rawurl string, q chan Event) er
|
|||
var s Stream
|
||||
err := conn.ReadJSON(&s)
|
||||
if err != nil {
|
||||
q <- &ErrorEvent{err: err}
|
||||
q <- &ErrorEvent{Err: err}
|
||||
|
||||
// Reconnect.
|
||||
break
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue