serpapi / google-search-results-ruby

Google Search Results via SERP API Ruby Gem
https://serpapi.com
MIT License
55 stars 9 forks source link

Raise more specific exceptions when API returns an error response #6

Closed michalvalasek closed 2 years ago

michalvalasek commented 4 years ago

Currently the library raises only a generic RuntimeError with message coming from the "error" field in the JSON body of the response. This is very generic and hard to react to.

The library could pass up more information about these error, e.g. by raising more specific exceptions.

jvmvik commented 4 years ago

The backend server has been upgraded to provided HTTP code. Would like you us to turn the HTTP status code into a Ruby exception ? for example: http status: 401 -> UnauthorizedException("body of the http response")