Exception: Startback::Errors::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Startback::Errors::Error
show all
- Defined in:
- lib/startback/errors.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(message = nil, causes = nil) ⇒ Error
Returns a new instance of Error.
5
6
7
8
|
# File 'lib/startback/errors.rb', line 5
def initialize(message = nil, causes = nil)
super(message)
@causes = Array(causes)
end
|
Instance Attribute Details
#causes ⇒ Object
Returns the value of attribute causes.
9
10
11
|
# File 'lib/startback/errors.rb', line 9
def causes
@causes
end
|
Class Method Details
.keep_error(keep = nil) ⇒ Object
20
21
22
23
|
# File 'lib/startback/errors.rb', line 20
def keep_error(keep = nil)
@keep_error = keep unless keep.nil?
@keep_error
end
|
.status(code = nil) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/startback/errors.rb', line 12
def status(code = nil)
if code.nil?
@code || (superclass.respond_to?(:status) ? superclass.status : 500)
else
@code = code || @code
end
end
|
Instance Method Details
#cause ⇒ Object
40
41
42
|
# File 'lib/startback/errors.rb', line 40
def cause
causes&.first
end
|
#has_causes? ⇒ Boolean
36
37
38
|
# File 'lib/startback/errors.rb', line 36
def has_causes?
causes && !causes.empty?
end
|
#message ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/startback/errors.rb', line 26
def message
msg = super
return msg unless msg == self.class.name
parts = self.class.name.split('::').last.gsub(/[A-Z]/){|x|
" #{x.downcase}"
}.strip.split(" ")
parts = parts[0...-1] unless self.class.keep_error
parts.join(" ").capitalize
end
|