net_http_timeout_errors 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
#
|
1
|
+
# NetHttpTimeoutErrors
|
2
2
|
|
3
3
|
Tired of having to rescue an ever-growing list of Net::HTTP timeout error types?
|
4
4
|
|
5
5
|
Just include this gem and then do:
|
6
6
|
|
7
|
-
```
|
7
|
+
``` ruby
|
8
8
|
begin
|
9
9
|
uri = URI.parse("http://google.com/")
|
10
10
|
response = Net::HTTP.get_response(uri)
|
11
|
-
rescue *
|
11
|
+
rescue *NetHttpTimeoutErrors.all
|
12
12
|
puts "It timed out some way or other!"
|
13
|
-
rescue AnotherError, *
|
13
|
+
rescue AnotherError, *NetHttpTimeoutErrors.all
|
14
14
|
puts "This works too."
|
15
15
|
end
|
16
16
|
```
|
@@ -1,8 +1,16 @@
|
|
1
1
|
require "minitest/autorun"
|
2
2
|
require "net_http_timeout_errors"
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe NetHttpTimeoutErrors, ".all" do
|
5
5
|
it "has some" do
|
6
|
-
|
6
|
+
NetHttpTimeoutErrors.all.wont_be_empty
|
7
|
+
end
|
8
|
+
|
9
|
+
# No assertions; more like runnable documentation.
|
10
|
+
it "works splatted" do
|
11
|
+
begin
|
12
|
+
raise Timeout::Error
|
13
|
+
rescue ZeroDivisionError, *NetHttpTimeoutErrors.all
|
14
|
+
end
|
7
15
|
end
|
8
16
|
end
|