Skip to content

Commit

Permalink
Raise OLResourceNotFound when receiving an empty response
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgumberg committed Oct 11, 2023
1 parent ebc1788 commit 1e2f59f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/fetchworks.rb
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 1e2f59f

Please sign in to comment.