Sha256: e37728f8bb56e5656dc75ab115d3b9f1c6cc471d4b5b3a4a904b5e6cb0490f54

Contents?: true

Size: 969 Bytes

Versions: 5

Compression:

Stored size: 969 Bytes

Contents

module SolidusMailchimpSync
  class Error < StandardError
    attr_reader :type, :title, :status, :detail, :instance,
                :request_method, :request_url, :request_body,
                :response_body, :response_hash

    def initialize( type:nil, title:nil, status: nil, detail: nil, instance: nil,
                    request_method:nil, request_url: nil, request_body: nil,
                    response_body: nil, response_hash: nil)

      @type = type
      @title = title
      @status = status
      @detail = detail
      @instance = instance

      @request_method = request_method.to_s.upcase
      @request_url = request_url
      @request_body = request_body

      @response_body = response_body
      @response_hash = response_hash

      super(constructed_message)
    end

    def constructed_message
      errors = response_hash.try { |h| h["errors"] }.to_s.presence
      [status, title, detail, errors].compact.join(': ')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_mailchimp_sync-1.0.0.beta05 app/models/solidus_mailchimp_sync/error.rb
solidus_mailchimp_sync-1.0.0.beta04 app/models/solidus_mailchimp_sync/error.rb
solidus_mailchimp_sync-1.0.0.beta03 app/models/solidus_mailchimp_sync/error.rb
solidus_mailchimp_sync-1.0.0.beta02 app/models/solidus_mailchimp_sync/error.rb
solidus_mailchimp_sync-1.0.0.beta01 app/models/solidus_mailchimp_sync/error.rb