Exception: StandardExceptions::Exception

Inherits:
StandardError
  • Object
show all
Defined in:
lib/standard_exceptions.rb

Overview

messages are based on httpstatuses.com

Constant Summary collapse

MESSAGE =
'An error occurred that could not be identified'
STATUS =
500

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, status = nil, inner = nil) ⇒ Exception



29
30
31
32
33
# File 'lib/standard_exceptions.rb', line 29

def initialize(message=nil,status=nil,inner=nil)
  super(message || self.class::MESSAGE)
  @status = (status || self.class::STATUS)
  @inner = inner
end

Instance Attribute Details

#innerObject



25
26
27
# File 'lib/standard_exceptions.rb', line 25

def inner
  @inner || self.cause
end

#statusObject

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_nameObject



20
21
22
# File 'lib/standard_exceptions.rb', line 20

def human_name
  self.class.human_name
end