Sha256: 21925df7ec5aadda5f60cf88f1d4a62ffb10fc0b0fabc1aa1d14f61f1b004e07

Contents?: true

Size: 628 Bytes

Versions: 1

Compression:

Stored size: 628 Bytes

Contents

module RDStation
  class ErrorHandler
    class ConflictingField
      attr_reader :api_response, :response_body, :error

      ERROR_CODE = 'CONFLICTING_FIELD'.freeze
      EXCEPTION_CLASS = RDStation::Error::ConflictingField

      def initialize(api_response)
        @api_response = api_response
        @error = JSON.parse(api_response.body)['errors']
      end

      def raise_error
        return unless conflicting_field?
        raise EXCEPTION_CLASS.new(error['error_message'], api_response)
      end

      private

      def conflicting_field?
        error['error_type'] == ERROR_CODE
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rdstation-ruby-client-1.0.0 lib/rdstation/error_handler/conflicting_field.rb