diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-10-04 10:55:36 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-10-04 10:55:36 -0700 |
commit | 524da347f58842a788e205877e0ff7079cb9bad3 (patch) | |
tree | 8a6f8a3858f8c2272db70c199542794db16b0169 /lib | |
parent | 64f27edacf6adda4b58406ef9f073c147465e077 (diff) | |
download | psych-524da347f58842a788e205877e0ff7079cb9bad3.zip |
adding more information to the syntax error exception
Diffstat (limited to 'lib')
-rw-r--r-- | lib/psych/syntax_error.rb | 18 |
1 files changed, 18 insertions, 0 deletions
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 |