Skip to content

Commit

Permalink
Improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
javiercr committed May 20, 2024
1 parent eddc2f5 commit 22c74d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion messagix/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func (c *Client) WaitUntilCanSendMessages(timeout time.Duration) error {
for !c.canSendMessages {
select {
case <-timer.C:
return fmt.Errorf("timeout waiting for sending messages")
return fmt.Errorf("timeout waiting for canSendMessages")
default:
c.sendMessagesCond.Wait()
}
Expand Down
5 changes: 4 additions & 1 deletion portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,10 @@ func (portal *Portal) handleMatrixMessage(ctx context.Context, sender *User, evt

retries := 0
for retries < MaxMetaSendAttempts {
sender.Client.WaitUntilCanSendMessages(15 * time.Second)
if err := sender.Client.WaitUntilCanSendMessages(15 * time.Second); err != nil {
log.Err(err).Msg("Error waiting to be able to send messages")
break
}
resp, err = sender.Client.ExecuteTasks(tasks...)
if err == nil {
break
Expand Down

0 comments on commit 22c74d2

Please sign in to comment.