Add some human-readable error messages

This commit is contained in:
Tulir Asokan 2023-08-08 18:57:23 +03:00
parent 9a45e6a534
commit b30d1fe7f8

View file

@ -50,10 +50,21 @@ var (
type OutgoingStatusError gmproto.MessageStatusType
func (ose OutgoingStatusError) Error() string {
return strings.TrimPrefix(string((gmproto.MessageStatusType)(ose).Descriptor().Name()), "OUTGOING_")
return strings.TrimPrefix(gmproto.MessageStatusType(ose).String(), "OUTGOING_")
}
func (ose OutgoingStatusError) HumanError() string {
switch gmproto.MessageStatusType(ose) {
case gmproto.MessageStatusType_OUTGOING_FAILED_TOO_LARGE:
return "too large"
case gmproto.MessageStatusType_OUTGOING_FAILED_RECIPIENT_LOST_RCS:
return "recipient lost RCS support"
case gmproto.MessageStatusType_OUTGOING_FAILED_RECIPIENT_LOST_ENCRYPTION:
return "recipient lost encryption support"
case gmproto.MessageStatusType_OUTGOING_FAILED_RECIPIENT_DID_NOT_DECRYPT,
gmproto.MessageStatusType_OUTGOING_FAILED_RECIPIENT_DID_NOT_DECRYPT_NO_MORE_RETRY:
return "recipient failed to decrypt message"
}
return ""
}