Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ext/psych/lib/psych/syntax_error.rb: Add file, line, offset, and
message attributes during parse failure. * ext/psych/parser.c: Update parser to raise exception with correct values. * test/psych/test_exception.rb: corresponding tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
- Loading branch information
1 parent
77e58a3
commit 137c547
Showing
4 changed files
with
62 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters