teslainventory_sdk/error.go
Matthieu 'JP' DERASSE 05ac49fd68
Some checks failed
continuous-integration/drone Build is failing
feat(first): First commit with basic implementation. Missing test
2023-08-09 12:11:17 +00:00

26 lines
494 B
Go

package teslastocksdk
import "fmt"
// APIError represent an API error.
type APIError struct {
StatusCode int `json:"-"`
Message string `json:"error"`
}
// Error satisfy the error interface.
func (a APIError) Error() string {
if a.Message != "" {
return fmt.Sprintf(
"HTTP response failed with status code %d, error message: %s",
a.StatusCode,
a.Message,
)
}
return fmt.Sprintf(
"HTTP response failed with status code %d and no error message",
a.StatusCode,
)
}