Class: OMCMS::ParseResponse

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/omcms/middleware/parse_response.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ParseResponse

Returns a new instance of ParseResponse.



5
6
7
8
# File 'lib/omcms/middleware/parse_response.rb', line 5

def initialize(app)
  super(app)
  @app = app
end

Instance Method Details

#on_complete(response_env) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/omcms/middleware/parse_response.rb', line 10

def on_complete(response_env)
  return OMCMS::Response::Error.new(response_env) if response_env.status >= 400

  response_env.body
rescue StandardError => e
  OMCMS::Response::Error.new(e)
end