Sha256: ce280252ed18cb87dca06bbc8afff1f78dca5ff3f01ac0360f974f0d99181469

Contents?: true

Size: 1012 Bytes

Versions: 2

Compression:

Stored size: 1012 Bytes

Contents

module YandexMoney
  class Error < StandardError; end

  class InsufficientScopeError < Error; end

  class UnauthorizedError < Error
    def initialize(error)
      @err = error
    end

    def message
      @err
    end
  end

  class FieldNotSetError < Error
    def initialize(field)
      @field = field
    end

    def message
      "Field '#{@field}' not set!"
    end
  end

  class ApiError < Error
    def initialize(msg)
      @msg = msg
    end

    def message
      @msg.gsub(/_/, " ").capitalize
    end
  end

  class AcceptTransferError < ApiError
    def initialize(msg, attemps = nil)
      @msg = msg
      @attemps = attemps
    end

    def message
      if @attemps
        super + ", attemps available: #{@attemps}"
      else
        super
      end
    end
  end

  class ExternalPaymentProgressError < ApiError
    def initialize(msg, next_retry)
      @msg = msg
      @next_retry = next_retry
    end

    def message
      super + ", next_retry: #{@next_retry}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yandex-money-sdk-0.11.0 lib/yandex_money/exceptions.rb
yandex-money-sdk-0.10.0 lib/yandex_money/exceptions.rb