-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patherrors.go
29 lines (24 loc) · 942 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
package tesla
import (
"errors"
"fmt"
)
// HTTPStatusError is returned if the response code received from the API is non-200.
type HTTPStatusError struct {
statusCode int
message string
}
func (err HTTPStatusError) Error() string {
if err.message == "" {
return fmt.Sprintf("http status error: %d", err.statusCode)
}
return fmt.Sprintf("http status error \"%s\": %d", err.message, err.statusCode)
}
var (
// ErrMissingRefreshToken is returned when an API call is made without the required refresh token.
ErrMissingRefreshToken = errors.New("missing refresh token")
// ErrMissingAccessToken is returned when an API call is made without the required access token.
ErrMissingAccessToken = errors.New("missing access token, authenticate first")
// ErrCommandError is returned with executing a command against the vehicle and the Tesla API returns an error message.
ErrCommandError = errors.New("error executing command")
)