small pixel drawing of a pufferfish j3s.sh

handle openlibrary errors a lil better
Jes Olson j3s@c3f.net
Tue, 15 Oct 2024 11:12:16 -0400
commit

545a06ba19516555c5d1f6412a1a00e5f80534a3

parent

624790b1631644986012017d91db5932acdbc96b

1 files changed, 2 insertions(+), 0 deletions(-)

jump to
M openlibrary/openlibrary.goopenlibrary/openlibrary.go

@@ -30,12 +30,14 @@ cb := CurrentBooks{}

resp, err := http.Get("https://openlibrary.org/people/j3sj3sj3s/books/currently-reading.json") if err != nil { fmt.Println(err) + return &cb } defer resp.Body.Close() body, err := io.ReadAll(resp.Body) err = json.Unmarshal(body, &cb) if err != nil { fmt.Println(err) + return &cb } return &cb }