Exception: Lookbook::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Lookbook::Error
show all
- Defined in:
- lib/lookbook/support/errors/error.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(message = nil, scope: nil, original: nil, status: nil, detail: nil, file_path: nil, source: nil, line_number: nil, **kwargs) ⇒ Error
Returns a new instance of Error.
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/lookbook/support/errors/error.rb', line 5
def initialize(message = nil,
scope: nil, original: nil, status: nil, detail: nil,
file_path: nil, source: nil, line_number: nil, **kwargs)
@scope = scope
@original = original
@message = message
@status = status
@detail = detail
@file_path = file_path
@source = source
@line_number = line_number
super(message)
end
|
Instance Attribute Details
#detail ⇒ Object
3
4
5
|
# File 'lib/lookbook/support/errors/error.rb', line 3
def detail
@detail
end
|
#original ⇒ Object
3
4
5
|
# File 'lib/lookbook/support/errors/error.rb', line 3
def original
@original
end
|
#scope ⇒ Object
3
4
5
|
# File 'lib/lookbook/support/errors/error.rb', line 3
def scope
@scope
end
|
#source ⇒ Object
3
4
5
|
# File 'lib/lookbook/support/errors/error.rb', line 3
def source
@source
end
|
#status ⇒ Object
3
4
5
|
# File 'lib/lookbook/support/errors/error.rb', line 3
def status
@status
end
|
Instance Method Details
#backtrace ⇒ Object
23
24
25
|
# File 'lib/lookbook/support/errors/error.rb', line 23
def backtrace
original&.backtrace || super
end
|
#backtrace_lines ⇒ Object
50
51
52
53
|
# File 'lib/lookbook/support/errors/error.rb', line 50
def backtrace_lines
root = Rails.root.to_s
backtrace.map { |line| line.gsub(root, "") }
end
|
#file_path ⇒ Object
31
32
33
34
35
|
# File 'lib/lookbook/support/errors/error.rb', line 31
def file_path
return @file_path.to_s if @file_path.present?
parsed_backtrace[0][0] if parsed_backtrace.any?
end
|
#line_number ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/lookbook/support/errors/error.rb', line 41
def line_number
return @line_number.to_i if @line_number.present?
if parsed_backtrace.any?
number = parsed_backtrace[0][1]
number.to_i if number.present?
end
end
|
#message ⇒ Object
19
20
21
|
# File 'lib/lookbook/support/errors/error.rb', line 19
def message
@message || original&.message
end
|
#relative_file_path ⇒ Object
37
38
39
|
# File 'lib/lookbook/support/errors/error.rb', line 37
def relative_file_path
file_path&.delete_prefix("#{Rails.root}/")
end
|
#type ⇒ Object
27
28
29
|
# File 'lib/lookbook/support/errors/error.rb', line 27
def type
(original.presence || self).class.to_s
end
|