Skip to content

Commit

Permalink
Handle error, CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
spolischook committed Sep 11, 2024
1 parent 39a9a50 commit 8aef75c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/router/handler/shopify/updateProducts.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ func (h *Handler) UpdateProducts(c *gin.Context) {

// Get all products from Shopify
shopifyProducts, err := shopify.GetAllProducts(h.Client)
if err != nil {
c.AbortWithStatusJSON(500, gin.H{"error": err.Error()})
return
}

// Update products
for _, aw := range existingArtWorks {
Expand Down Expand Up @@ -59,7 +63,7 @@ func (h *Handler) UpdateProducts(c *gin.Context) {
}
}

if false == isNew {
if !isNew {
continue
}

Expand All @@ -70,7 +74,7 @@ func (h *Handler) UpdateProducts(c *gin.Context) {
500,
gin.H{
fmt.Sprintf(`error create %d %s:`, aw.ID, aw.Title): err.Error()},
)
)
return
}

Expand All @@ -90,8 +94,8 @@ func (h *Handler) UpdateProducts(c *gin.Context) {
// Create image
_, err = h.Client.Image.Create(createdProduct.ID, aw.ShopifyImage())
if err != nil {
c.AbortWithStatusJSON(http.StatusBadGateway, gin.H{"error": err.Error()})
}
c.AbortWithStatusJSON(http.StatusBadGateway, gin.H{"error": err.Error()})
}

aw.UpdateShopifyProduct(createdProduct)
createdProduct, err = h.Client.Product.Update(*createdProduct)
Expand Down

0 comments on commit 8aef75c

Please sign in to comment.