2019-05-30 10:20:56 +00:00
|
|
|
package whatsapp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2020-08-24 21:35:08 +00:00
|
|
|
|
2019-05-30 10:20:56 +00:00
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2019-10-26 23:45:57 +00:00
|
|
|
ErrAlreadyConnected = errors.New("already connected")
|
|
|
|
ErrAlreadyLoggedIn = errors.New("already logged in")
|
|
|
|
ErrInvalidSession = errors.New("invalid session")
|
|
|
|
ErrLoginInProgress = errors.New("login or restore already running")
|
|
|
|
ErrNotConnected = errors.New("not connected")
|
|
|
|
ErrInvalidWsData = errors.New("received invalid data")
|
|
|
|
ErrInvalidWsState = errors.New("can't handle binary data when not logged in")
|
|
|
|
ErrConnectionTimeout = errors.New("connection timed out")
|
|
|
|
ErrMissingMessageTag = errors.New("no messageTag specified or to short")
|
|
|
|
ErrInvalidHmac = errors.New("invalid hmac")
|
|
|
|
ErrInvalidServerResponse = errors.New("invalid response received from server")
|
|
|
|
ErrServerRespondedWith404 = errors.New("server responded with status 404")
|
|
|
|
ErrMediaDownloadFailedWith404 = errors.New("download failed with status code 404")
|
|
|
|
ErrMediaDownloadFailedWith410 = errors.New("download failed with status code 410")
|
2020-08-24 21:35:08 +00:00
|
|
|
ErrInvalidWebsocket = errors.New("invalid websocket")
|
2019-05-30 10:20:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ErrConnectionFailed struct {
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *ErrConnectionFailed) Error() string {
|
|
|
|
return fmt.Sprintf("connection to WhatsApp servers failed: %v", e.Err)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ErrConnectionClosed struct {
|
|
|
|
Code int
|
|
|
|
Text string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *ErrConnectionClosed) Error() string {
|
|
|
|
return fmt.Sprintf("server closed connection,code: %d,text: %s", e.Code, e.Text)
|
|
|
|
}
|