Exception: Voodoo::Parser::MultipleErrors

Inherits:
Error
  • Object
show all
Defined in:
lib/voodoo/parser.rb

Overview

Class wrapping multiple Parser::Errors.

Instance Attribute Summary collapse

Attributes inherited from Error

#input_name, #start_column, #start_line

Instance Method Summary collapse

Constructor Details

#initialize(errors) ⇒ MultipleErrors

Returns a new instance of MultipleErrors.



86
87
88
89
90
# File 'lib/voodoo/parser.rb', line 86

def initialize errors
  @errors = errors
  super(nil, errors[0].input_name, errors[0].start_line,
        errors[0].start_column, nil)
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



92
93
94
# File 'lib/voodoo/parser.rb', line 92

def errors
  @errors
end

Instance Method Details

#messageObject



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/voodoo/parser.rb', line 94

def message
  if @message == nil
    msg = "Multiple errors:\n\n"
    @errors.each do |error|
      msg << error.input_name << ":" if error.input_name
      msg << "#{error.start_line}: " << error.message
      if error.text != nil
        msg << "\n\n  #{error.text.gsub("\n", "\n  ")}"
      end
      msg << "\n"
    end
    @message = msg
  end
  @message
end

#textObject



110
111
112
113
114
115
116
# File 'lib/voodoo/parser.rb', line 110

def text
  if @text == nil
    texts = @errors.map {|error| error.text}
    @text = texts.join "\n"
  end
  @text
end