better-faraday 1.0.1 → 1.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
  SHA256:
3
- metadata.gz: 07d700f220555c731b5821d0ea84557aac50f44338e419a4d240d154014e10f0
4
- data.tar.gz: 5ffcc44a9e1b2760f289f62b8854832c1e538659199997876975bfb3bd2df326
3
+ metadata.gz: 520161498209165aa279351373198c4f82936380767f5bbffa6bd02e9698527f
4
+ data.tar.gz: aadd3384613e59c8855b8432895c5ac6ef2a2afbbeddd82d689ddd05022be2be
5
5
  SHA512:
6
- metadata.gz: f49be213d5da70ff089584888620365c0798d77cbbd4ce1c9aed5dfe7271e8bf5b7aea80866b57cd000e41de3c5cb726f9727a00a79568ea77869f839b875371
7
- data.tar.gz: 10ec106368e57def4cdf1ccc81fbf08e56da0b9706f0a63145967d9946a01ebc479545ca703cac3776f4ef5b945bdb0f12f5af4cb81734c902590eed0285cb93
6
+ metadata.gz: be5bd473d0551db70328a71d4b1ae0a880de59ee0b60fc8826d2899583f771b66300d59c71c9e48ac833c16854c964cda23b6e25bad4a0811a221721b9bcb3c6
7
+ data.tar.gz: e329ceb0a76522e17d52502ec5e13a2bad7d14c9b2c5b887e7a1d042e6dfb59e80ecc7b0fdd27eae50d347733c20a66d2fb255d748eee1955f294ba0a70a21c4
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "better-faraday"
6
- s.version = "1.0.1"
6
+ s.version = "1.0.2"
7
7
  s.author = "Yaroslav Konoplov"
8
8
  s.email = "eahome00@gmail.com"
9
9
  s.summary = "Extends Faraday with useful features."
@@ -1,8 +1,11 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
3
 
4
- require "faraday"
5
4
  require "json"
5
+ require "faraday"
6
+ require "faraday/error"
7
+ require "faraday/options"
8
+ require "faraday/response"
6
9
 
7
10
  Module.new do
8
11
  def run_request(method, url, body, headers, &block)
@@ -15,12 +18,23 @@ module Faraday
15
18
  attr_reader :request_body
16
19
  end
17
20
 
21
+ class Error
22
+ attr_reader :response
23
+ end
24
+
18
25
  class Response
19
26
  def assert_2xx!
20
27
  return self if status >= 200 && status <= 299
21
- raise Faraday::HTTP422, describe if status == 422
22
- raise Faraday::HTTP4xx, describe if status >= 400 && status <= 499
23
- raise Faraday::Error, describe
28
+ klass = if status == 422
29
+ Faraday::HTTP422
30
+ elsif status >= 400 && status <= 499
31
+ Faraday::HTTP4xx
32
+ else
33
+ Faraday::Error
34
+ end
35
+ error = klass.new(describe)
36
+ error.instance_variable_set(:@response, self)
37
+ raise error
24
38
  end
25
39
 
26
40
  alias ok! assert_2xx! # Short name.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better-faraday
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Konoplov