Exception: Twig::Error::Base
- Inherits:
-
StandardError
- Object
- StandardError
- Twig::Error::Base
show all
- Defined in:
- lib/twig/error/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(message, lineno = -1,, source = nil, previous = nil) ⇒ Base
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/twig/error/base.rb', line 12
def initialize(message, lineno = -1, source = nil, previous = nil)
super('')
@lineno = lineno
@source = source
@raw_message = message
@previous = previous
update_repr
end
|
Instance Attribute Details
#lineno ⇒ Integer
7
8
9
|
# File 'lib/twig/error/base.rb', line 7
def lineno
@lineno
end
|
Instance Method Details
#append_message(raw_message) ⇒ Object
43
44
45
46
|
# File 'lib/twig/error/base.rb', line 43
def append_message(raw_message)
@raw_message += raw_message
update_repr
end
|
#guess ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/twig/error/base.rb', line 48
def guess
locations = [self, @previous].compact.map(&:backtrace_locations).flatten
locations.each do |location|
next if location.nil?
next unless location.label&.start_with?('Twig::Compiled::')
klass, _method = location.label.split('#')
klass = Twig::Compiled.const_get(klass)
next unless source.name == klass.source_context.name
klass.debug_info.each do |source_line, template_line|
next unless source_line <= location.lineno
self.lineno = template_line
update_repr
return
end
end
end
|
#source_context ⇒ Source?
24
25
26
|
# File 'lib/twig/error/base.rb', line 24
def source_context
@source
end
|
#source_context=(source) ⇒ Object
29
30
31
32
|
# File 'lib/twig/error/base.rb', line 29
def source_context=(source)
@source = source
update_repr
end
|
#to_s ⇒ Object
34
35
36
|
# File 'lib/twig/error/base.rb', line 34
def to_s
@message
end
|