diff options
Diffstat (limited to 'ext/psych/lib/psych/syntax_error.rb')
-rw-r--r-- | ext/psych/lib/psych/syntax_error.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/psych/lib/psych/syntax_error.rb b/ext/psych/lib/psych/syntax_error.rb new file mode 100644 index 0000000000..f79743dba4 --- /dev/null +++ b/ext/psych/lib/psych/syntax_error.rb @@ -0,0 +1,19 @@ +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 ' ' + filename = file || '<unknown>' + message = "(%s): %s at line %d column %d" % [filename, err, line, col] + + @file = file + @line = line + @column = col + @offset = offset + @problem = problem + @context = context + super(message) + end + end +end |