summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Rhymen/go-whatsapp/errors.go
blob: 793f8cc9e3ef4bc355289d0e03aacb75fb9fea26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package whatsapp

import (
	"fmt"
	"github.com/pkg/errors"
)

var (
	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")
	ErrConnectionTimeout = errors.New("connection timed out")
	ErrMissingMessageTag = errors.New("no messageTag specified or to short")
	ErrInvalidHmac       = errors.New("invalid hmac")
)

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)
}