Exception: PinPayment::Error
- Inherits:
-
StandardError
- Object
- StandardError
- PinPayment::Error
- Defined in:
- lib/pin_payment/error.rb
Direct Known Subclasses
InvalidResource, InvalidResponse, ResourceNotFound, TokenAlreadyUsed
Defined Under Namespace
Classes: InvalidResource, InvalidResponse, ResourceNotFound, TokenAlreadyUsed
Class Method Summary collapse
Class Method Details
.create(type, description, messages = nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/pin_payment/error.rb', line 4 def self.create type, description, = nil klass = case type when 'token_already_used'; TokenAlreadyUsed when 'invalid_resource'; InvalidResource when 'resource_not_found'; ResourceNotFound else self end if .is_a?(Array) description = description + ' ' + .map{|x| "(#{x['message']})" }.join(' & ') elsif .is_a?(Hash) description = description + ' ' + .values.flatten.map{|x| "(#{x})" }.join(' & ') end klass.new(description) end |