Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

net_http_timeout_errors

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

net_http_timeout_errors

  • 1.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

NetHttpTimeoutErrors

Whether you use Net::HTTP or some higher abstraction like HTTParty, are you tired of having to rescue an ever-growing list of Net::HTTP timeout error types?

Just load this gem and then do:

begin
  uri = URI.parse("http://google.com/")
  response = Net::HTTP.get_response(uri)
rescue *NetHttpTimeoutErrors.all
  puts "It timed out some way or other!"
rescue AnotherError, *NetHttpTimeoutErrors.all
  puts "This works too."
end

Or if you prefer:

begin
  NetHttpTimeoutErrors.conflate do
    uri = URI.parse("http://google.com/")
    response = Net::HTTP.get_response(uri)
  end
rescue NetHttpTimeoutError
  puts "It timed out some way or other!"
end

You can still get at the original error through NetHttpTimeoutError#original_error.

Did we miss an error? Please add it!

Installation

Add this line to your application's Gemfile:

gem 'net_http_timeout_errors'

And then execute:

$ bundle

Or install it yourself as:

$ gem install net_http_timeout_errors

Also see

There is also net_http_exception_fix which cleverly tags these exceptions with a Net::HTTPBroken module that you can rescue.

You may prefer about this library that it very explicitly raises a single exception. The tagged exceptions are less obviously the same.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 04 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc