Exception: Templator::ParseError

Inherits:
Exception
  • Object
show all
Defined in:
lib/templator/parameter_dsl.rb

Overview

Error wrapper of all errors occuring during the parsing of a parameter file. This wrapper provides convenient methods to retrieve the origin of the error.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_exception, file) ⇒ ParseError

Returns a new instance of ParseError.



56
57
58
59
60
61
# File 'lib/templator/parameter_dsl.rb', line 56

def initialize(original_exception, file)
  @original_exception = original_exception
  @file = file

  process original_exception
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



54
55
56
# File 'lib/templator/parameter_dsl.rb', line 54

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



54
55
56
# File 'lib/templator/parameter_dsl.rb', line 54

def line
  @line
end

Instance Method Details

#message_to_sObject



64
65
66
# File 'lib/templator/parameter_dsl.rb', line 64

def message_to_s
  @message.sub(/\A.*:\d+:\s*/, "")
end

#origin_to_sObject



68
69
70
# File 'lib/templator/parameter_dsl.rb', line 68

def origin_to_s
  "in file #{file}" + (@line ? " line #{@line}" : "")
end

#to_sObject



73
74
75
# File 'lib/templator/parameter_dsl.rb', line 73

def to_s
  "ParseError #{origin_to_s}: #{message_to_s}"
end