Sha256: 54d7a89c41dfcd2c97db68bb0cd0b5a0d2bc7761d8011a8faa96fa052f6907f2

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 Bytes

Contents

module Hws::Connectors::Exception
  class Error < StandardError
    attr_accessor :reason

    def initialize(err = nil)
      case err.class.name
      when 'Hash'
        @reason = err['reason']
        super(err['message'])
      else
        super(err)
      end
    end
  end

  class UnAuthorized < Error
    def initialize(msg = 'Invalid credentials')
      super(msg)
    end
  end

  class LowBalance < Error
    def initialize(msg = 'Your account balance is low')
      super(msg)
    end
  end

  class RatelimitExceeded < Error
    def initialize(msg = 'You have exceeded the number of attempts')
      super(msg)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hws-connectors-0.1.1 lib/hws-connectors/exception.rb
hws-connectors-0.1.0 lib/hws-connectors/exception.rb