lib/wlang/errors.rb in wlang-0.8.4 vs lib/wlang/errors.rb in wlang-0.8.5
- old
+ new
@@ -1,37 +1,16 @@
module WLang
# Main error of all WLang errors.
class Error < StandardError; end
+ # Raise when something fails when evaluting through the parser context
+ class EvalError < StandardError; end
+
# Error raised by a WLang parser instanciation when an error occurs.
- class ParseError < StandardError;
-
- attr_reader :line, :column
-
- # Creates an error with offset information
- def initialize(message, offset=nil, template=nil)
- @offset = offset
- @line, @column = parse(template) if template
- unless template and offset
- super(message)
- else
- super("ParseError at #{@line}:#{@column} : #{message}")
- end
-
- end
+ class ParseError < StandardError;
- # Reparses the template and finds line:column locations
- def parse(template)
- template = template[0,@offset]
- if template =~ /\n/ then
- lines = template[0,@offset].split(/\n/)
- else
- lines = [template]
- end
- line, column = lines.length, lines.last.length
- return [line, column]
- end
+ attr_accessor :line, :column
- end # class ParseError
+ end
end # module WLang