Skip to content

Commit

Permalink
mataroa: improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Aug 15, 2024
1 parent c963e20 commit c23a49b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mataroa.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type mataroaResponse struct {
Title string `json:"title"`
Url string `json:"url"`
Slug string `json:"slug"`
// Error string `json:"error"`
Error string `json:"error"`
}

type mataroaPostRequest struct {
Expand Down Expand Up @@ -145,12 +145,16 @@ func publishToMataroa(posts posts) {
p, resp = mustPatchMataroaPost(p.Slug, post)
log.Printf("[UPDATED] (code=%d): %+v\n", resp.StatusCode, p)
}
} else {
log.Printf("[ERROR] %s: %+v\n", post.slug, resp)
}

if resp.StatusCode != 200 {
panic(fmt.Sprintf("non-200 response for post: %s", post.slug))
err := fmt.Errorf(
"non-200 (code=%d) status code for post=%s, response: %+v",
resp.StatusCode,
post.slug,
resp,
)
panic(err)
}
}
}

0 comments on commit c23a49b

Please sign in to comment.