-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy patherrors.go
31 lines (26 loc) · 806 Bytes
/
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
package powerwall
import (
"fmt"
"net/url"
)
// ApiError indicates that something unexpected occurred with the HTTP API
// call. This usually occurs when the endpoint returns an unexpected status
// code.
type ApiError struct {
URL url.URL
StatusCode int
Body []byte
}
func (e ApiError) Error() string {
return fmt.Sprintf("API call to %s returned unexpected status code %d (%#v)", e.URL.String(), e.StatusCode, string(e.Body))
}
// AuthFailure is returned when the client was unable to perform a request
// because it was not able to login using the provided email and password.
type AuthFailure struct {
URL url.URL
ErrorText string
Message string
}
func (e AuthFailure) Error() string {
return fmt.Sprintf("Authentication Failed: %s (%s)", e.ErrorText, e.Message)
}