From 524da347f58842a788e205877e0ff7079cb9bad3 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 4 Oct 2011 10:55:36 -0700 Subject: adding more information to the syntax error exception --- lib/psych/syntax_error.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lib/psych/syntax_error.rb (limited to 'lib') diff --git a/lib/psych/syntax_error.rb b/lib/psych/syntax_error.rb new file mode 100644 index 0000000..9fe3e0d --- /dev/null +++ b/lib/psych/syntax_error.rb @@ -0,0 +1,18 @@ +module Psych + class SyntaxError < ::SyntaxError + attr_reader :file, :line, :column, :offset, :problem, :context + + def initialize file, line, col, offset, problem, context + err = [problem, context].compact.join ' ' + message = "(%s): %s at line %d column %d" % [file, err, line, col] + + @file = file + @line = line + @column = col + @offset = offset + @problem = problem + @context = context + super(message) + end + end +end -- cgit v1.2.3