diff --git a/lib/calendlyr/resource.rb b/lib/calendlyr/resource.rb index 37ca791..83d259f 100644 --- a/lib/calendlyr/resource.rb +++ b/lib/calendlyr/resource.rb @@ -50,7 +50,12 @@ def request(url, req_type, body: {}, params: {}, base_url: Client::BASE_URL) def handle_response(response) return true unless response.read_body - body = JSON.parse(response.read_body) + body = begin + JSON.parse(response.read_body) + rescue + {} + end + if ERROR_CODES.include? response.code raise ResponseErrorHandler.new(response.code, body).error else