fix: panic stack without sender, log service error frames, refresh account on reconnect
- handler panic log includes the stack trace and no longer the sender number - error and exception frames from the service are logged at Warn level - Listen looks the account up again after a connection loss (re-link) - document that received but unhandled messages are lost at shutdown Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
788dd0b968
commit
b54aab1534
5 files changed
+162
-3
No files matched your search
+36
@@ -82,3 +82,39 @@ func parseEnvelope(data []byte, self Account) (Message, bool) {
|
||||
}
|
||||
return m, true
|
||||
}
|
||||
|
||||
// serviceError extracts an error reported by the service on the receive
|
||||
// websocket: a top-level "error" (string or {"message"}), or a signal-cli
|
||||
// "exception" (e.g. a message that could not be decrypted).
|
||||
func serviceError(data []byte) (string, bool) {
|
||||
var f struct {
|
||||
Error json.RawMessage `json:"error"`
|
||||
Exception *struct {
|
||||
Message string `json:"message"`
|
||||
Type string `json:"type"`
|
||||
} `json:"exception"`
|
||||
}
|
||||
if json.Unmarshal(data, &f) != nil {
|
||||
return "", false
|
||||
}
|
||||
if len(f.Error) > 0 && string(f.Error) != "null" {
|
||||
var s string
|
||||
if json.Unmarshal(f.Error, &s) == nil {
|
||||
return s, true
|
||||
}
|
||||
var o struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
if json.Unmarshal(f.Error, &o) == nil && o.Message != "" {
|
||||
return o.Message, true
|
||||
}
|
||||
return string(f.Error), true
|
||||
}
|
||||
if f.Exception != nil {
|
||||
if f.Exception.Type != "" {
|
||||
return f.Exception.Type + ": " + f.Exception.Message, true
|
||||
}
|
||||
return f.Exception.Message, true
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
Reference in new issue
Block a user