Sha256: 89eb99e9e82c197d7fe5e00e6d586ff6ba5d846328ec5e8f17521c5666c37eb1

Contents?: true

Size: 707 Bytes

Versions: 8

Compression:

Stored size: 707 Bytes

Contents

module LocaSMS

  # Common base exception
  class Exception < ::Exception
    attr_reader :raw, :action

    def initialize(data = {})
      @raw    = data[:raw]
      @action = data[:data]

      super data[:message] || default_message
    end

  private

    def default_message
      nil
    end
  end

  # Raised when asked for an invalid operation
  # @see https://github.com/mcorp/locasms/wiki/A-API-de-envio#lista-das-a%C3%A7%C3%B5es-dispon%C3%ADveis
  class InvalidOperation < Exception
    def default_message
      'Invalid Operation'
    end
  end

  # Raised when the given credentials are invalid
  class InvalidLogin < Exception
    def default_message
      'Invalid Login'
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
locasms-0.4.0 lib/locasms/exception.rb
locasms-0.3.1 lib/locasms/exception.rb
locasms-0.3.0 lib/locasms/exception.rb
locasms-0.2.0 lib/locasms/exception.rb
locasms-0.1.7 lib/locasms/exception.rb
locasms-0.1.6 lib/locasms/exception.rb
locasms-0.1.5 lib/locasms/exception.rb
locasms-0.1.4 lib/locasms/exception.rb