error: add RespError.CanRetry field (#456)
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run

This commit is contained in:
Nick Mills-Barrett 2026-01-29 15:01:48 +00:00 committed by GitHub
commit 4b387c305b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -142,6 +142,8 @@ type RespError struct {
StatusCode int
ExtraHeader map[string]string
CanRetry bool
}
func (e *RespError) UnmarshalJSON(data []byte) error {
@ -151,6 +153,7 @@ func (e *RespError) UnmarshalJSON(data []byte) error {
}
e.ErrCode, _ = e.ExtraData["errcode"].(string)
e.Err, _ = e.ExtraData["error"].(string)
e.CanRetry, _ = e.ExtraData["com.beeper.can_retry"].(bool)
return nil
}
@ -158,6 +161,9 @@ func (e *RespError) MarshalJSON() ([]byte, error) {
data := exmaps.NonNilClone(e.ExtraData)
data["errcode"] = e.ErrCode
data["error"] = e.Err
if e.CanRetry {
data["com.beeper.can_retry"] = e.CanRetry
}
return json.Marshal(data)
}
@ -188,6 +194,11 @@ func (e RespError) WithStatus(status int) RespError {
return e
}
func (e RespError) WithCanRetry(canRetry bool) RespError {
e.CanRetry = canRetry
return e
}
func (e RespError) WithExtraData(extraData map[string]any) RespError {
e.ExtraData = exmaps.NonNilClone(e.ExtraData)
maps.Copy(e.ExtraData, extraData)