Skip to content

Commit

Permalink
Include error in CAT refresh error event
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Feb 27, 2024
1 parent 1bdd11e commit c5e8575
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions connectionevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (cli *Client) handleStreamError(node *waBinary.Node) {
if err != nil {
cli.Log.Errorf("Failed to refresh CAT: %v", err)
cli.expectDisconnect()
go cli.dispatchEvent(&events.CATRefreshError{})
go cli.dispatchEvent(&events.CATRefreshError{Error: err})
}
default:
cli.Log.Errorf("Unknown stream error: %s", node.XMLString())
Expand Down Expand Up @@ -134,7 +134,7 @@ func (cli *Client) handleConnectFailure(node *waBinary.Node) {
if err != nil {
cli.Log.Errorf("Failed to refresh CAT: %v", err)
cli.expectDisconnect()
go cli.dispatchEvent(&events.CATRefreshError{})
go cli.dispatchEvent(&events.CATRefreshError{Error: err})
}
} else if willAutoReconnect {
cli.Log.Warnf("Got %d/%s connect failure, assuming automatic reconnect will handle it", int(reason), message)
Expand Down
4 changes: 3 additions & 1 deletion types/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ type ConnectFailure struct {
// ClientOutdated is emitted when the WhatsApp server rejects the connection with the ConnectFailureClientOutdated code.
type ClientOutdated struct{}

type CATRefreshError struct{}
type CATRefreshError struct {
Error error
}

// StreamError is emitted when the WhatsApp server sends a <stream:error> node with an unknown code.
//
Expand Down

0 comments on commit c5e8575

Please sign in to comment.