-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
37 lines (29 loc) · 793 Bytes
/
errors.go
File metadata and controls
37 lines (29 loc) · 793 Bytes
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
36
37
package libws
import (
"net/url"
"fmt"
"github.com/pkg/errors"
)
var (
ErrConnectionClosed = errors.New("connection has been closed")
ErrCannotConnect = errors.New("connection cannot be established")
ErrTerminated = errors.New("program exit")
ErrRateLimit = errors.New("rate limit exceeded")
)
type ErrUnrecoverableConnection struct {
err error
url url.URL
}
func (e ErrUnrecoverableConnection) Error() string {
return fmt.Sprintf("Unrecoverable connection error: %s to %s", e.err, e.url.String())
}
func (e ErrUnrecoverableConnection) Unwrap() error { return e.err }
func WrapErrorUnrecoverableConnection(err error, url url.URL) *ErrUnrecoverableConnection {
if err != nil {
return nil
}
return &ErrUnrecoverableConnection{
err: err,
url: url,
}
}