Skip to content

Commit 8f08c21

Browse files
committed
added inventory error handling
1 parent 2d4e86e commit 8f08c21

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

shopify/shopify.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"encoding/json"
2323
"errors"
2424
"fmt"
25+
"io/ioutil"
2526
"net/http"
2627
"net/http/cookiejar"
2728
"net/url"
@@ -144,7 +145,6 @@ func (shopifyClient *Shopify) PlaceOrder(order OrderResponse) (Order, error) {
144145
if err != nil {
145146
return shopifyResponse.SingleOrder, err
146147
}
147-
148148
return shopifyResponse.SingleOrder, nil
149149
}
150150

@@ -265,6 +265,12 @@ func (shopifyClient *Shopify) makeRequest(method string, urlStr string, body int
265265
jww.ERROR.Printf("[makeRequest] - Rate limited!\n")
266266
rateLimitErr := errors.New("API rate limit exceeded")
267267
return rateLimitErr
268+
} else if resp.StatusCode == 422 {
269+
message, _ := ioutil.ReadAll(resp.Body)
270+
message = bytes.Replace(message, []byte("\\u003e"), []byte(">"), -1)
271+
jww.ERROR.Printf("[makeRequest] - %s\n", message)
272+
inventoryErr := errors.New(string(message))
273+
return inventoryErr
268274
}
269275
if err != nil {
270276
jww.ERROR.Printf("[makeRequest] - Error executing request : %s", err)

0 commit comments

Comments
 (0)