Sha256: cf82983955f72fbc6235dd6481d326eaba4a445d164960ff8a9a4418e602e872

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 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.8.0 lib/epics/middleware/parse_ebics.rb