19 lines
387 B
Go
19 lines
387 B
Go
|
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,
|
||
|
)
|
||
|
}
|