Class: Common::Client::Middleware::Response::VETextError

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/common/client/middleware/response/vetext_errors.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/common/client/middleware/response/vetext_errors.rb', line 8

def on_complete(env)
  return if env.success?

  Rails.logger.info('VEText Service Error', body: env.body, status: env.status)
  case env.status
  when 400..499
    raise Common::Exceptions::BackendServiceException.new('VETEXT_PUSH_400', {}, env.status,
                                                          env.body)
  when 500..599
    raise Common::Exceptions::BackendServiceException.new('VETEXT_PUSH_502', {}, env.status)
  else
    raise 'Unexpected VEText Error'
  end
end