From 1e2f59fa154ee81d1d89b3406996bc032772c3ac Mon Sep 17 00:00:00 2001 From: David Gumberg Date: Wed, 11 Oct 2023 00:56:55 -0400 Subject: [PATCH] Raise OLResourceNotFound when receiving an empty response --- lib/fetchworks.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/fetchworks.rb b/lib/fetchworks.rb index f8b8a9a..9d09f25 100644 --- a/lib/fetchworks.rb +++ b/lib/fetchworks.rb @@ -67,7 +67,10 @@ def self.get_book(isbn) raise OLBadStatus, response&.status end - JSON.parse(response.read).values.first + response_body = response&.read + raise OLResourceNotFound unless response_body != "{}" + + JSON.parse(response_body).values.first end def self.get_author(url)