Sha256: 2b36d7ec66278d992ce84a434b0d18ff442d87e68b8e1afd3f6919e81ac964e0

Contents?: true

Size: 1.79 KB

Versions: 19

Compression:

Stored size: 1.79 KB

Contents

module Bobot
  # Base Facebook Messenger exception.
  class Error < ::StandardError; end

  class InvalidParameter < ::ArgumentError
    def initialize(name, description = "")
      super("invalid value of parameter #{name}#{description.present? ? ": '#{description}'" : ''}")
    end
  end

  class FieldFormat < ::ArgumentError
    def initialize(description)
      super("invalid field value with API limits: #{description}")
    end
  end

  # Forbidden Action exception
  class ActionNotAllowed < Bobot::Error; end

  # Base error class for Facebook API errors.
  class FacebookError < Bobot::Error
    attr_reader :message
    attr_reader :type
    attr_reader :code
    attr_reader :subcode
    attr_reader :user_title
    attr_reader :user_msg
    attr_reader :fbtrace_id

    def initialize(error)
      @message = error['message']
      @type = error['type']
      @code = error['code']
      @subcode = error['error_subcode']
      @user_title = error['error_user_title']
      @user_msg = error['error_user_msg']
      @fbtrace_id = error['fbtrace_id']
    end

    def to_s
      message
    end
  end

  # Base Facebook Messenger send API exception.
  class SendError < Bobot::FacebookError; end

  class AccessTokenError < Bobot::SendError; end
  class AccountLinkingError < Bobot::SendError; end
  class BadParameterError < Bobot::SendError; end
  class InternalError < Bobot::SendError; end
  class LimitError < Bobot::SendError; end
  class PermissionError < Bobot::SendError; end

  # Base Facebook Messenger exception.
  class NetworkError < ::StandardError
    attr_reader :response
    attr_reader :description

    def initialize(response, description)
      @response = response
      @description = description
    end

    def message
      description
    end

    def to_s
      message
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
bobot-3.6.3 lib/bobot/exceptions.rb
bobot-3.6.0 lib/bobot/exceptions.rb
bobot-3.5.2 lib/bobot/exceptions.rb
bobot-3.5.1 lib/bobot/exceptions.rb
bobot-3.5.0 lib/bobot/exceptions.rb
bobot-3.0.7 lib/bobot/exceptions.rb
bobot-3.0.6 lib/bobot/exceptions.rb
bobot-3.0.5 lib/bobot/exceptions.rb
bobot-3.0.3 lib/bobot/exceptions.rb
bobot-3.0.2 lib/bobot/exceptions.rb
bobot-3.0.1 lib/bobot/exceptions.rb
bobot-2.6.2 lib/bobot/exceptions.rb
bobot-2.6.1 lib/bobot/exceptions.rb
bobot-2.6.0 lib/bobot/exceptions.rb
bobot-2.5.0 lib/bobot/exceptions.rb
bobot-2.3.0 lib/bobot/exceptions.rb
bobot-2.1.0 lib/bobot/exceptions.rb
bobot-1.0.53 lib/bobot/exceptions.rb
bobot-1.0.52 lib/bobot/exceptions.rb