Module: Kybus::Exceptions::HTTP

Defined in:
lib/kybus/http_exceptions.rb

Overview

Provides basic execptions for http common errors.

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.new_http_exception(class_name, http_code, type) ⇒ Object



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

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