Sha256: 246e4d9164e384f74a547eb2f7bf665c17a8292b9a564df304ff57da64a863b7

Contents?: true

Size: 1.41 KB

Versions: 17

Compression:

Stored size: 1.41 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
      msg += " => #{response.body}" if response&.body
      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

17 entries across 17 versions & 1 rubygems

Version Path
jabber_admin-1.6.0 lib/jabber_admin/errors.rb
jabber_admin-1.5.1 lib/jabber_admin/errors.rb
jabber_admin-1.5.0 lib/jabber_admin/errors.rb
jabber_admin-1.4.0 lib/jabber_admin/exceptions.rb
jabber_admin-1.3.4 lib/jabber_admin/exceptions.rb
jabber_admin-1.3.3 lib/jabber_admin/exceptions.rb
jabber_admin-1.3.2 lib/jabber_admin/exceptions.rb
jabber_admin-1.3.1 lib/jabber_admin/exceptions.rb
jabber_admin-1.3.0 lib/jabber_admin/exceptions.rb
jabber_admin-1.2.0 lib/jabber_admin/exceptions.rb
jabber_admin-1.1.0 lib/jabber_admin/exceptions.rb
jabber_admin-1.0.5 lib/jabber_admin/exceptions.rb
jabber_admin-1.0.4 lib/jabber_admin/exceptions.rb
jabber_admin-1.0.3 lib/jabber_admin/exceptions.rb
jabber_admin-1.0.2 lib/jabber_admin/exceptions.rb
jabber_admin-1.0.1 lib/jabber_admin/exceptions.rb
jabber_admin-1.0.0 lib/jabber_admin/exceptions.rb