summaryrefslogtreecommitdiff
path: root/ext/psych/lib/psych/syntax_error.rb
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-06 23:12:37 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-06 23:12:37 +0000
commit54b214cc23652250c2dde01940d8778360363d54 (patch)
treed528923bab372daf6bfa8bf00de5e9a12250fe56 /ext/psych/lib/psych/syntax_error.rb
parentc5fada686d160b0caedb9af40ffcc75995e88edb (diff)
* ext/psych/lib/psych.rb (module Psych): parse and load methods take
an optional file name that is used when raising Psych::SyntaxError exceptions * ext/psych/lib/psych/syntax_error.rb (module Psych): allow nil file names and handle nil file names in the exception message * test/psych/test_exception.rb (module Psych): Tests for changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych/lib/psych/syntax_error.rb')
-rw-r--r--ext/psych/lib/psych/syntax_error.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/psych/lib/psych/syntax_error.rb b/ext/psych/lib/psych/syntax_error.rb
index 9fe3e0da30..f79743dba4 100644
--- a/ext/psych/lib/psych/syntax_error.rb
+++ b/ext/psych/lib/psych/syntax_error.rb
@@ -3,8 +3,9 @@ module Psych
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]
+ err = [problem, context].compact.join ' '
+ filename = file || '<unknown>'
+ message = "(%s): %s at line %d column %d" % [filename, err, line, col]
@file = file
@line = line