Sha256: e09682f82108dc55f7b246a1089e9c01dd57b4f232cebda03fa82e1fe297c2dc

Contents?: true

Size: 755 Bytes

Versions: 1

Compression:

Stored size: 755 Bytes

Contents

# frozen_string_literal: true

class Epics::ParseEbics < Faraday::Middleware
  def initialize(app = nil, options = {})
    super(app)
    @client = options[:client]
  end

  def call(env)
    @app.call(env).on_complete do |response|
      response[:body] = ::Epics::Response.new(@client, response[:body])
      raise Epics::Error::TechnicalError, response[:body].technical_code if response[:body].technical_error?
      raise Epics::Error::BusinessError, response[:body].business_code if response[:body].business_error?
    end
  rescue Epics::Error::TechnicalError, Epics::Error::BusinessError
    raise # re-raise as otherwise they would be swallowed by the following rescue
  rescue StandardError => e
    raise Epics::Error::UnknownError, e
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
epics-1.7.2 lib/epics/middleware/parse_ebics.rb