Module: Ant::Exceptions::HTTP

Defined in:
lib/ant/http_exceptions.rb

Constant Summary collapse

EXCEPTION_TYPES =
{
  success: Ant::Exceptions::AntSuccess,
  fail: Ant::Exceptions::AntFail,
  error: Ant::Exceptions::AntError
}.freeze

Class Method Summary collapse

Class Method Details

.new_http_exception(class_name, http_code, type) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ant/http_exceptions.rb', line 15

def new_http_exception(class_name, http_code, type)
  parent = exception_type(type)
  http_exception_class = Class.new(parent) do
    def initialize(message, object = {})
      super(message, nil, object)
    end

    define_method 'http_code' do
      http_code
    end
  end

  const_set(class_name, http_exception_class)
end