forked from ngrok/ngrok-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
115 lines (93 loc) · 2.34 KB
/
errors.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package ngrok
import (
"fmt"
"net/url"
)
// Errors arising from authentication failure.
type errAuthFailed struct {
// Whether the error was generated by the remote server, or in the sending
// of the authentication request.
Remote bool
// The underlying error.
Inner error
}
func (e errAuthFailed) Error() string {
var msg string
if e.Remote {
msg = "authentication failed"
} else {
msg = "failed to send authentication request"
}
return fmt.Sprintf("%s: %v", msg, e.Inner)
}
func (e errAuthFailed) Unwrap() error {
return e.Inner
}
func (e errAuthFailed) Is(target error) bool {
_, ok := target.(errAuthFailed)
return ok
}
// The error returned by [Tunnel]'s [net.Listener.Accept] method.
type errAcceptFailed struct {
// The underlying error.
Inner error
}
func (e errAcceptFailed) Error() string {
return fmt.Sprintf("failed to accept connection: %v", e.Inner)
}
func (e errAcceptFailed) Unwrap() error {
return e.Inner
}
func (e errAcceptFailed) Is(target error) bool {
_, ok := target.(errAcceptFailed)
return ok
}
// Errors arising from a failure to start a tunnel.
type errListen struct {
// The underlying error.
Inner error
}
func (e errListen) Error() string {
return fmt.Sprintf("failed to start tunnel: %v", e.Inner)
}
func (e errListen) Unwrap() error {
return e.Inner
}
func (e errListen) Is(target error) bool {
_, ok := target.(errListen)
return ok
}
// Errors arising from a failure to construct a [golang.org/x/net/proxy.Dialer] from a [url.URL].
type errProxyInit struct {
// The provided proxy URL.
URL *url.URL
// The underlying error.
Inner error
}
func (e errProxyInit) Error() string {
return fmt.Sprintf("failed to construct proxy dialer from \"%s\": %v", e.URL.String(), e.Inner)
}
func (e errProxyInit) Unwrap() error {
return e.Inner
}
func (e errProxyInit) Is(target error) bool {
_, ok := target.(errProxyInit)
return ok
}
// Error arising from a failure to dial the ngrok server.
type errSessionDial struct {
// The address to which a connection was attempted.
Addr string
// The underlying error.
Inner error
}
func (e errSessionDial) Error() string {
return fmt.Sprintf("failed to dial ngrok server with address \"%s\": %v", e.Addr, e.Inner)
}
func (e errSessionDial) Unwrap() error {
return e.Inner
}
func (e errSessionDial) Is(target error) bool {
_, ok := target.(errSessionDial)
return ok
}