lib/shiprocket_api/connection.rb in shiprocket_api-0.2.0 vs lib/shiprocket_api/connection.rb in shiprocket_api-0.3.0

- old
+ new

@@ -28,7 +28,16 @@ rescue Timeout::Error => e raise ActiveResource::TimeoutError.new(e.message) rescue OpenSSL::SSL::SSLError => e raise ActiveResource::SSLError.new(e.message) end + + # Handles response and error codes from the remote service. + def handle_response(response) + if response.code.to_i == 200 && JSON.parse(response.body).keys.include?("message") + raise CreationError.new(response) + else + super + end + end end end \ No newline at end of file