|
|
package errors |
|
|
|
|
|
import ( |
|
|
"fmt" |
|
|
"strconv" |
|
|
) |
|
|
|
|
|
|
|
|
type ConfigError struct { |
|
|
Field string |
|
|
Reason string |
|
|
} |
|
|
|
|
|
func (c ConfigError) Error() string { |
|
|
return fmt.Sprintf("invalid config: %s: %s", c.Field, c.Reason) |
|
|
} |
|
|
|
|
|
|
|
|
type ConnectError struct { |
|
|
Err error |
|
|
} |
|
|
|
|
|
func (c ConnectError) Error() string { |
|
|
return "connect error: " + c.Err.Error() |
|
|
} |
|
|
|
|
|
func (c ConnectError) Unwrap() error { |
|
|
return c.Err |
|
|
} |
|
|
|
|
|
|
|
|
type AuthError struct { |
|
|
StatusCode int |
|
|
} |
|
|
|
|
|
func (a AuthError) Error() string { |
|
|
return "authentication error, HTTP status code: " + strconv.Itoa(a.StatusCode) |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type DialError struct { |
|
|
Message string |
|
|
} |
|
|
|
|
|
func (c DialError) Error() string { |
|
|
return "dial error: " + c.Message |
|
|
} |
|
|
|
|
|
|
|
|
type ClosedError struct { |
|
|
Err error |
|
|
} |
|
|
|
|
|
func (c ClosedError) Error() string { |
|
|
if c.Err == nil { |
|
|
return "connection closed" |
|
|
} else { |
|
|
return "connection closed: " + c.Err.Error() |
|
|
} |
|
|
} |
|
|
|
|
|
func (c ClosedError) Unwrap() error { |
|
|
return c.Err |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type ProtocolError struct { |
|
|
Message string |
|
|
} |
|
|
|
|
|
func (p ProtocolError) Error() string { |
|
|
return "protocol error: " + p.Message |
|
|
} |
|
|
|