Sha256: d70b48e5ac1eada6608ac497f96d8576ff487171854064254135e4b74776bac7

Contents?: true

Size: 839 Bytes

Versions: 11

Compression:

Stored size: 839 Bytes

Contents

module PagarMe
  class PagarMeError < StandardError
	attr_accessor :message
	attr_accessor :parameter_name
	attr_accessor :type
	attr_accessor :url
	attr_accessor :errors

	def initialize(message = "", parameter_name = "", type = "", url = "") 
	  self.message = message
	  self.type = type
	  self.parameter_name = parameter_name
	  self.errors = []
	end

	def self.initFromServerResponse(response = {})
	  object = self.new
		response['errors'].map do |error|
		  object.message += error['message'] + ', '
		  object.errors << PagarMeError.new(error['message'],  error['parameter_name'], error['type'], response['url'])
		end
		object
	end
	
	def to_s
	  "#{self.class.to_s} - #{message}"
	end
  end

  class RequestError < PagarMeError
  end

  class ConnectionError < PagarMeError
  end

  class ResponseError < PagarMeError
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pagarme-1.9.2 lib/pagarme/errors.rb
pagarme-1.9.1 lib/pagarme/errors.rb
pagarme-1.9 lib/pagarme/errors.rb
pagarme-1.8 lib/pagarme/errors.rb
pagarme-1.7 lib/pagarme/errors.rb
pagarme-1.5 lib/pagarme/errors.rb
pagarme-1.4 lib/pagarme/errors.rb
pagarme-1.3 lib/pagarme/errors.rb
pagarme-1.2 lib/pagarme/errors.rb
pagarme-1.1 lib/pagarme/errors.rb
pagarme-1.0 lib/pagarme/errors.rb