Skip to content

Commit

Permalink
improved error handling in send method
Browse files Browse the repository at this point in the history
* when a message is successfully sent, signal-cli returns a timestamp,
  which we convert to an integer. in case, we, for some reason can't
  convert the timestamp to an integer, it means that signal-cli returned
  some non-numeric characters as well (which is a strong indication that
  there was an error). So, instead of returning the parsing error,
  return the actual signal-cli error message.

see #412
  • Loading branch information
Bernhard B committed Oct 4, 2023
1 parent 661fe56 commit 6f269d3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ func (s *SignalClient) send(number string, message string,
resp.Timestamp, err = strconv.ParseInt(strings.TrimSuffix(rawData, "\n"), 10, 64)
if err != nil {
cleanupAttachmentEntries(attachmentEntries)
return nil, err
return nil, errors.New(strings.Replace(rawData, "\n", "", -1)) //in case we can't parse the timestamp, it means signal-cli threw an error. So instead of returning the parsing error, return the actual error from signal-cli
}
}

Expand Down

0 comments on commit 6f269d3

Please sign in to comment.