datatrans/error.go
2021-03-03 15:23:20 +01:00

27 lines
494 B
Go

package datatrans
import "fmt"
type ErrorResponse struct {
HTTPStatusCode int
ErrorDetail ErrorDetail `json:"error"`
}
// see https://docs.datatrans.ch/docs/error-messages
type ErrorDetail struct {
Code string `json:"code"`
Message string `json:"message"`
}
func (s ErrorResponse) Error() string {
if s.ErrorDetail.Code == "" {
return ""
}
return fmt.Sprintf(
"HTTPStatusCode:%d Code:%q, Message:%q",
s.HTTPStatusCode,
s.ErrorDetail.Code,
s.ErrorDetail.Message,
)
}