refactor: return ErrNoSuchAPIID any time we get 422

This commit is contained in:
James Houlahan
2020-04-17 12:12:44 +02:00
parent 49a64a656c
commit c6f32192b9
5 changed files with 13 additions and 10 deletions

View File

@ -17,6 +17,8 @@
package pmapi
import "net/http"
// Common response codes.
const (
CodeOk = 1000
@ -35,6 +37,10 @@ type Res struct {
// Err returns error if the response is an error. Otherwise, returns nil.
func (res Res) Err() error {
if res.StatusCode == http.StatusUnprocessableEntity {
return ErrNoSuchAPIID
}
if res.ResError == nil {
return nil
}