From 0dac4ec6be5d89bb17ca474516e9b900d361f1b4 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 15 Dec 2006 18:05:39 +0000 Subject: Changing some of the error output. This gets rid of the duplicated information that occurred when definitions or nodes were duplicately defined, and it tightens the error output a bit. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1938 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/error.rb | 2 +- lib/puppet/parser/interpreter.rb | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/puppet/error.rb b/lib/puppet/error.rb index 64b877fda..b70a4dddf 100644 --- a/lib/puppet/error.rb +++ b/lib/puppet/error.rb @@ -23,7 +23,7 @@ module Puppet # :nodoc: def to_s str = nil if defined? @file and defined? @line and @file and @line - str = "%s in file %s at line %s" % + str = "%s at %s:%s" % [@message.to_s, @file, @line] elsif defined? @line and @line str = "%s at line %s" % diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index ec3267b8b..884080ec0 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -479,8 +479,7 @@ class Puppet::Parser::Interpreter if other = @classtable[fqname] # Make sure the parents match if parent and other.parentclass and (parent != other.parentclass) - @parser.error @parser.addcontext("Class %s is already defined" % fqname) + - " with parent %s" % [fqname, other.parentclass] + @parser.error("Class %s is already defined at %s:%s; cannot redefine" % [fqname, other.file, other.line]) end # This might be dangerous... @@ -527,10 +526,7 @@ class Puppet::Parser::Interpreter end # Make sure our definition doesn't already exist if other = @definetable[fqname] - @parser.error @parser.addcontext( - "%s is already defined at line %s" % [fqname, other.line], - other - ) + @parser.error("%s is already defined at %s:%s; cannot redefine" % [fqname, other.file, other.line]) end ns, name = namesplit(fqname) @@ -555,7 +551,7 @@ class Puppet::Parser::Interpreter names = [names] unless names.instance_of?(Array) names.collect do |name| if other = @nodetable[name] - @parser.error @parser.addcontext("Node %s is already defined" % [other.name], other) + @parser.error("Node %s is already defined at %s:%s; cannot redefine" % [other.name, other.file, other.line]) end name = name.to_s if name.is_a?(Symbol) args = { -- cgit