Class: CiscoMSE::Middleware::ExceptionRaiser
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- CiscoMSE::Middleware::ExceptionRaiser
- Defined in:
- lib/cisco-mse-client/middleware/exception_raiser.rb
Overview
Raise beautiful exceptions
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cisco-mse-client/middleware/exception_raiser.rb', line 19 def call(env) begin @app.call(env) rescue Faraday::Error::ClientError => e if e.response exception = case e.response[:status] when 404 CiscoMSE::NotFoundError when 500 CiscoMSE::ServiceError else CiscoMSE::GenericException end raise exception, e.response else raise CiscoMSE::GenericException, e end rescue Saddle::TimeoutError => e raise CiscoMSE::TimeoutError, e.response end end |