Sha256: 8f76bc04298b4a91ee0ee564461a35cfdf22581534ea37e49aa95d213ad4dd2d

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module JabberAdmin
  # The base exception which all other exceptions inherit. In case you want to
  # use our error handling with the bang variants, you can rescue all
  # exceptions like this:
  #
  #   begin
  #     JabberAdmin.COMMAND!
  #   rescue JabberAdmin::Error => err
  #     # Do your error handling here
  #   end
  class Error < StandardError
    attr_accessor :response

    # Create a new exception.
    #
    # @param msg [String] the excpetion message
    # @param response [RestClient::Response] the response when available
    def initialize(msg, response = nil)
      @response = response
      super(msg)
    end
  end

  # This exception is raised when the request was denied due to premission
  # issues or a general unavaliability of the command on the REST API. This
  # simply means the response code from ejabberd was not 200 OK.
  class RequestError < Error; end

  # This exception is raised when the response from the ejabberd REST API
  # indicated that the status of the command was not successful. In this case
  # the response body includes a one (1). In case everything was fine, it
  # includes a zero (0).
  class CommandError < Error; end

  # This exception is raised when we send an unknown command to the REST API.
  # It will respond with a 404 status code in this case.
  class UnknownCommandError < Error; end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jabber_admin-0.2.0 lib/jabber_admin/exceptions.rb