diff --git a/lib/solana_rpc_ruby/api_client.rb b/lib/solana_rpc_ruby/api_client.rb index ea0cd77..3169950 100644 --- a/lib/solana_rpc_ruby/api_client.rb +++ b/lib/solana_rpc_ruby/api_client.rb @@ -53,6 +53,7 @@ def call_api(body:, http_method:, params: {}) Net::HTTPNotFound, Net::HTTPClientException, Net::HTTPFatalError, + Net::HTTPTooManyRequests, Net::ReadTimeout, Errno::ECONNREFUSED, SocketError => e diff --git a/spec/lib/solana_rpc_ruby/api_client_spec.rb b/spec/lib/solana_rpc_ruby/api_client_spec.rb index 6edf64e..feba1f8 100644 --- a/spec/lib/solana_rpc_ruby/api_client_spec.rb +++ b/spec/lib/solana_rpc_ruby/api_client_spec.rb @@ -88,6 +88,18 @@ end end + describe 'Net::HTTPTooManyRequests' do + it 'raise error correctly' do + allow(http).to \ + receive(:request).with(an_instance_of(Net::HTTP::Post)) + .and_raise(Net::HTTPTooManyRequests.new('1.1', 429, '')) + + expect do + described_class.new.call_api(body: {}, http_method: :post) + end.to raise_error(SolanaRpcRuby::ApiError, 'Net::HTTPTooManyRequests') + end + end + describe 'Net::ReadTimeout' do it 'raise error correctly' do allow(http).to \