Exception: Locomotive::Steam::RenderError

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

Constant Summary collapse

LINES_RANGE =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of RenderError.



15
16
17
18
# File 'lib/locomotive/steam/errors.rb', line 15

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 (readonly)

Returns the value of attribute file.



13
14
15
# File 'lib/locomotive/steam/errors.rb', line 13

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



13
14
15
# File 'lib/locomotive/steam/errors.rb', line 13

def line
  @line
end

#original_backtraceObject (readonly)

Returns the value of attribute original_backtrace.



13
14
15
# File 'lib/locomotive/steam/errors.rb', line 13

def original_backtrace
  @original_backtrace
end

#sourceObject (readonly)

Returns the value of attribute source.



13
14
15
# File 'lib/locomotive/steam/errors.rb', line 13

def source
  @source
end

Instance Method Details

#backtraceObject



32
33
34
# File 'lib/locomotive/steam/errors.rb', line 32

def backtrace
  original_backtrace
end

#code_linesObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/locomotive/steam/errors.rb', line 20

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

  lines = source.split("\n")

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

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