Class: Krack::Error
- Inherits:
-
Object
- Object
- Krack::Error
- Defined in:
- lib/krack/error.rb
Instance Attribute Summary collapse
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(status = 500) ⇒ Error
constructor
A new instance of Error.
- #to_h ⇒ Object
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
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/krack/error.rb', line 3 def status @status end |
Instance Method Details
#to_h ⇒ Object
9 10 11 |
# File 'lib/krack/error.rb', line 9 def to_h {error: {status: status, message: Rack::Utils::HTTP_STATUS_CODES[status]}} end |