Exception: StandardExceptions::Exception
- Inherits:
-
StandardError
- Object
- StandardError
- StandardExceptions::Exception
- Defined in:
- lib/standard_exceptions.rb
Overview
messages are based on httpstatuses.com
Direct Known Subclasses
Http::BadRequest, Http::Forbidden, Http::InternalServerError, Http::NotFound, Http::Unauthorized, Http::UnprocessableEntity
Constant Summary collapse
- MESSAGE =
'An error occurred that could not be identified'- STATUS =
500
Instance Attribute Summary collapse
- #inner ⇒ Object
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #human_name ⇒ Object
-
#initialize(message = nil, status = nil, inner = nil) ⇒ Exception
constructor
A new instance of Exception.
Constructor Details
#initialize(message = nil, status = nil, inner = nil) ⇒ Exception
29 30 31 32 33 |
# File 'lib/standard_exceptions.rb', line 29 def initialize(=nil,status=nil,inner=nil) super( || self.class::MESSAGE) @status = (status || self.class::STATUS) @inner = inner end |
Instance Attribute Details
#inner ⇒ Object
25 26 27 |
# File 'lib/standard_exceptions.rb', line 25 def inner @inner || self.cause end |
#status ⇒ Object
Returns the value of attribute status.
11 12 13 |
# File 'lib/standard_exceptions.rb', line 11 def status @status end |
Class Method Details
.human_name(e_class = self) ⇒ Object
eg. ‘Not Found’
14 15 16 17 18 |
# File 'lib/standard_exceptions.rb', line 14 def self.human_name(e_class=self) i = e_class.name.rindex('::') base_name = e_class.name[(i+2)..-1] base_name.split(/(?=[A-Z])/).join(' ') end |
Instance Method Details
#human_name ⇒ Object
20 21 22 |
# File 'lib/standard_exceptions.rb', line 20 def human_name self.class.human_name end |