Class: Common::Client::Middleware::Response::RaiseError
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Common::Client::Middleware::Response::RaiseError
- Defined in:
- lib/common/client/middleware/response/raise_error.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#error_prefix ⇒ Object
readonly
Returns the value of attribute error_prefix.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(app, options = {}) ⇒ RaiseError
constructor
A new instance of RaiseError.
- #on_complete(env) ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ RaiseError
Returns a new instance of RaiseError.
12 13 14 15 16 |
# File 'lib/common/client/middleware/response/raise_error.rb', line 12 def initialize(app, = {}) # set the error prefix to something like 'RX' or 'SM' @error_prefix = [:error_prefix] || 'VA' super(app) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
10 11 12 |
# File 'lib/common/client/middleware/response/raise_error.rb', line 10 def body @body end |
#error_prefix ⇒ Object (readonly)
Returns the value of attribute error_prefix.
10 11 12 |
# File 'lib/common/client/middleware/response/raise_error.rb', line 10 def error_prefix @error_prefix end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/common/client/middleware/response/raise_error.rb', line 10 def status @status end |
Instance Method Details
#on_complete(env) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/common/client/middleware/response/raise_error.rb', line 18 def on_complete(env) return if env.success? @body = env[:body] @status = env.status.to_i raise_error! end |