Sha256: fbdf41db18c6201b2c2cfbdfedf5d4a0a9faaa01b8c9cda516aa743140e143a8

Contents?: true

Size: 1.66 KB

Versions: 11

Compression:

Stored size: 1.66 KB

Contents

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

  class FieldFormat < ::ArgumentError
    def initialize(description, value = nil)
      super("#{description}#{value.present? ? " : #{value}'" : ''}")
    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
    attr_reader :extras

    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']
      @extras = error['extras']
    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

11 entries across 11 versions & 1 rubygems

Version Path
bobot-5.0.4 lib/bobot/exceptions.rb
bobot-5.0.3 lib/bobot/exceptions.rb
bobot-5.0.2 lib/bobot/exceptions.rb
bobot-5.0.1 lib/bobot/exceptions.rb
bobot-5.0.0 lib/bobot/exceptions.rb
bobot-4.15.0 lib/bobot/exceptions.rb
bobot-4.14.0 lib/bobot/exceptions.rb
bobot-4.13.1 lib/bobot/exceptions.rb
bobot-4.13.0 lib/bobot/exceptions.rb
bobot-4.11.0 lib/bobot/exceptions.rb
bobot-4.10.0 lib/bobot/exceptions.rb