Class: CapsuleCRM::Faraday::Middleware::RaiseError

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/capsule_crm/faraday/middleware/raise_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#error_factory=(value) ⇒ Object

Sets the attribute error_factory

Parameters:

  • value

    the value to set the attribute error_factory to.



5
6
7
# File 'lib/capsule_crm/faraday/middleware/raise_error.rb', line 5

def error_factory=(value)
  @error_factory = value
end

Instance Method Details

#on_complete(env) ⇒ Object



7
8
9
10
# File 'lib/capsule_crm/faraday/middleware/raise_error.rb', line 7

def on_complete(env)
  return if env[:status] < 400
  raise error_factory.error_from_env(env)
end