3pl/partnerapi/onpoint/error.go

26 lines
506 B
Go
Raw Normal View History

2022-09-16 10:43:13 +00:00
package onpoint
2022-10-04 08:45:29 +00:00
import (
"fmt"
"strings"
)
2022-09-16 10:43:13 +00:00
// Error ...
type Error struct {
2022-10-04 08:45:29 +00:00
Message string `json:"message"`
Code string `json:"code"`
Errors map[string][]string `json:"errors"`
2022-09-16 10:43:13 +00:00
}
// Error ...
func (e Error) Error() string {
2022-10-04 08:45:29 +00:00
msg := fmt.Sprintf("onpoint_err: code %s, message: %s", e.Code, e.Message)
if len(e.Errors) > 0 {
msg += "\ndetail: "
for k, v := range e.Errors {
msg += fmt.Sprintf("field %s - error %s", k, strings.Join(v, ","))
}
}
return msg
2022-09-16 10:43:13 +00:00
}