From 54b214cc23652250c2dde01940d8778360363d54 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Tue, 6 Dec 2011 23:12:37 +0000 Subject: * 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 --- ext/psych/lib/psych/syntax_error.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ext/psych/lib/psych/syntax_error.rb') 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 || '' + message = "(%s): %s at line %d column %d" % [filename, err, line, col] @file = file @line = line -- cgit v1.2.3