Exception: Locomotive::Steam::ParsingRenderingError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/locomotive/steam/errors.rb

Direct Known Subclasses

ActionError, RenderError

Constant Summary collapse

LINES_RANGE =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, file, source, line, original_backtrace) ⇒ ParsingRenderingError

Returns a new instance of ParsingRenderingError.



23
24
25
26
# File 'lib/locomotive/steam/errors.rb', line 23

def initialize(message, file, source, line, original_backtrace)
  @file, @source, @line, @original_backtrace = file, source, line, original_backtrace
  super(message)
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



21
22
23
# File 'lib/locomotive/steam/errors.rb', line 21

def file
  @file
end

#lineObject

Returns the value of attribute line.



21
22
23
# File 'lib/locomotive/steam/errors.rb', line 21

def line
  @line
end

#original_backtraceObject

Returns the value of attribute original_backtrace.



21
22
23
# File 'lib/locomotive/steam/errors.rb', line 21

def original_backtrace
  @original_backtrace
end

#sourceObject

Returns the value of attribute source.



21
22
23
# File 'lib/locomotive/steam/errors.rb', line 21

def source
  @source
end

Instance Method Details

#backtraceObject



40
41
42
# File 'lib/locomotive/steam/errors.rb', line 40

def backtrace
  original_backtrace
end

#code_linesObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/locomotive/steam/errors.rb', line 28

def code_lines
  return [] if source.blank? || line.nil?

  lines = source.split("\n")

  start   = line - (LINES_RANGE / 2)
  start   = 1 if start <= 0
  finish  = line + (LINES_RANGE / 2)

  (start..finish).map { |i| [i, lines[i - 1]] }
end