Class: Krack::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/krack/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status = 500) ⇒ Error

Returns a new instance of Error.



5
6
7
# File 'lib/krack/error.rb', line 5

def initialize(status=500)
  @status = Rack::Utils::HTTP_STATUS_CODES.has_key?(status) ? status : 500
end

Instance Attribute Details

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/krack/error.rb', line 3

def status
  @status
end

Instance Method Details

#to_hObject



9
10
11
# File 'lib/krack/error.rb', line 9

def to_h
  {error: {status: status, message: Rack::Utils::HTTP_STATUS_CODES[status]}}
end