Tesla/api/error.go

19 lines
387 B
Go
Raw Normal View History

2023-06-05 13:41:48 +00:00
package api
import "fmt"
// Error represent an API Error.
type Error struct {
HTTPCode int `json:"-"`
HTTPMessage string `json:"-"`
}
// Error statisfy the standard Error interface and return a human readeable message.
func (a Error) Error() string {
return fmt.Sprintf(
"API call failed with the following error: %s (HTTP status: %d)",
a.HTTPMessage,
a.HTTPCode,
)
}