http-exceptions 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4f964f5cbcb049627ba3c17a4ba5de848c1be6a
4
- data.tar.gz: 0ede8bb30f5ff1c9f5f17a2bd1f85c068600aa28
3
+ metadata.gz: 7ffca1fda1f057ce3a70dc47630a23fd567de208
4
+ data.tar.gz: 19c46b249e069e3e5c5ce90b39edf979e23a62f9
5
5
  SHA512:
6
- metadata.gz: 1860ed474db6fdef517eb965bf5d07a62d9822e9cc864f72aec9b08cc43e54065a89aa823d382d1cc87a73de978274d105e4ff297caa6caed0c4080792cbf55d
7
- data.tar.gz: 2dffd435df203216e3f119e4f06433db0c1a3c46a2b11030f00ea1e5c0735c9be4e8c9dbdc65026426647151db1ce19f2dfe8442c6989eb3ffb489a0ddfdf9b5
6
+ metadata.gz: 2cfbced68908a3db07560fd8fe00104b3fe5e2167b52368d272b4f4d199911fcebf149ce6d8fa8fd1a32aac3897a64411f176d2f90ed23bc412e60aab551f0a9
7
+ data.tar.gz: 15a95d10cd078497d30925bddd477ae76bb96a420001815019a4921500ea9e931ccb917089caa66fe59df42c506e83045de8e928dd5e4697b29610569444cd46
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 2.1.2@http-exceptions --create
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Http::Exceptions provides an easy way to rescue exceptions that might be thrown by your Http library.
4
4
 
5
+ If you're using a library such as the excellent [HTTParty](https://github.com/jnunemaker/httparty), you still have to deal with various types of exceptions. In an ideal world, the return code of the HTTP request would be the sole indicator of failures, but HTTP libraries can raise a large number of exceptions (such as `SocketError` or `Net::ReadTimeout`) that you need to handle.
6
+
7
+ Http::Exceptions converts any error that might be raised by your HTTP library and wrap it in a `Http::Exceptions::HttpException`.
8
+
5
9
  ## Installation
6
10
 
7
11
  Add this line to your application's Gemfile:
@@ -21,26 +25,38 @@ Or install it yourself as:
21
25
  Only rescue raised exceptions.
22
26
 
23
27
  ```ruby
24
- Http::Exceptions.wrap_exception do
25
- Httparty.get "http://www.google.com"
26
- end
28
+ response = Http::Exceptions.wrap_exception do
29
+ HTTParty.get "http://www.google.com"
30
+ end
27
31
  ```
28
32
 
29
33
  Raise an exception is the return code of the API call is not `2XX`.
30
34
 
31
35
  ```ruby
32
- Http::Exceptions.wrap_and_check do
33
- Httparty.get "http://www.google.com"
36
+ response = Http::Exceptions.wrap_and_check do
37
+ HTTParty.get "http://www.google.com"
38
+ end
39
+ ```
40
+
41
+ You can then rescue the exception in the following way:
42
+
43
+ ```ruby
44
+ begin
45
+ response = Http::Exceptions.wrap_and_check do
46
+ HTTParty.get "http://www.google.com"
34
47
  end
48
+ rescue Http::Exceptions::HttpException => e
49
+ # ...
50
+ end
35
51
  ```
36
52
 
37
53
  ### Support
38
54
 
39
- Currently, this only has been tested with HTTP party. It could however be easily extended for other libraries as most of them just delegate to the ruby http library.
55
+ Currently, this only has been tested with HTTParty. It should however work with any library that delegates to the ruby http library.
40
56
 
41
57
  ## Contributing
42
58
 
43
- 1. Fork it ( https://github.com/[my-github-username]/http-exceptions/fork )
59
+ 1. Fork it ( https://github.com/rainforestapp/http-exceptions/fork )
44
60
  2. Create your feature branch (`git checkout -b my-new-feature`)
45
61
  3. Commit your changes (`git commit -am 'Add some feature'`)
46
62
  4. Push to the branch (`git push origin my-new-feature`)
@@ -1,5 +1,5 @@
1
1
  module Http
2
2
  module Exceptions
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -12,7 +12,8 @@ module Http
12
12
  Errno::ECONNREFUSED,
13
13
  Errno::EHOSTDOWN,
14
14
  Errno::ECONNRESET,
15
- OpenSSL::SSL::SSLError
15
+ OpenSSL::SSL::SSLError,
16
+ EOFError,
16
17
  ].freeze
17
18
 
18
19
  def self.wrap_exception
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-exceptions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Mathieu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-07 00:00:00.000000000 Z
11
+ date: 2014-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -46,6 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".gitignore"
49
+ - ".rvmrc"
49
50
  - Gemfile
50
51
  - LICENSE.txt
51
52
  - README.md