diff options
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/errors.go')
-rw-r--r-- | vendor/go.mau.fi/whatsmeow/errors.go | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/errors.go b/vendor/go.mau.fi/whatsmeow/errors.go index 8b68bd0e..d11cbb37 100644 --- a/vendor/go.mau.fi/whatsmeow/errors.go +++ b/vendor/go.mau.fi/whatsmeow/errors.go @@ -15,11 +15,10 @@ import ( // Miscellaneous errors var ( - ErrNoSession = errors.New("can't encrypt message for device: no signal session established") - ErrIQTimedOut = errors.New("info query timed out") - ErrIQDisconnected = errors.New("websocket disconnected before info query returned response") - ErrNotConnected = errors.New("websocket not connected") - ErrNotLoggedIn = errors.New("the store doesn't contain a device JID") + ErrNoSession = errors.New("can't encrypt message for device: no signal session established") + ErrIQTimedOut = errors.New("info query timed out") + ErrNotConnected = errors.New("websocket not connected") + ErrNotLoggedIn = errors.New("the store doesn't contain a device JID") ErrAlreadyConnected = errors.New("websocket is already connected") @@ -47,6 +46,10 @@ var ( ErrBusinessMessageLinkNotFound = errors.New("that business message link does not exist or has been revoked") // ErrInvalidImageFormat is returned by SetGroupPhoto if the given photo is not in the correct format. ErrInvalidImageFormat = errors.New("the given data is not a valid image") + // ErrMediaNotAvailableOnPhone is returned by DecryptMediaRetryNotification if the given event contains error code 2. + ErrMediaNotAvailableOnPhone = errors.New("media no longer available on phone") + // ErrUnknownMediaRetryError is returned by DecryptMediaRetryNotification if the given event contains an unknown error code. + ErrUnknownMediaRetryError = errors.New("unknown media retry error") ) // Some errors that Client.SendMessage can return @@ -54,7 +57,6 @@ var ( ErrBroadcastListUnsupported = errors.New("sending to broadcast lists is not yet supported") ErrUnknownServer = errors.New("can't send message to unknown server") ErrRecipientADJID = errors.New("message recipient must be normal (non-AD) JID") - ErrSendDisconnected = errors.New("websocket disconnected before message send returned response") ) // Some errors that Client.Download can return @@ -157,3 +159,23 @@ type ElementMissingError struct { func (eme *ElementMissingError) Error() string { return fmt.Sprintf("missing <%s> element in %s", eme.Tag, eme.In) } + +var ErrIQDisconnected = &DisconnectedError{Action: "info query"} + +// DisconnectedError is returned if the websocket disconnects before an info query or other request gets a response. +type DisconnectedError struct { + Action string + Node *waBinary.Node +} + +func (err *DisconnectedError) Error() string { + return fmt.Sprintf("websocket disconnected before %s returned response", err.Action) +} + +func (err *DisconnectedError) Is(other error) bool { + otherDisc, ok := other.(*DisconnectedError) + if !ok { + return false + } + return otherDisc.Action == err.Action +} |