diff options
author | Luke Kanies <luke@madstop.com> | 2005-07-16 16:44:04 +0000 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2005-07-16 16:44:04 +0000 |
commit | 357afbbc6054dcdc7a1fd5ae468a2e86a44a9bde (patch) | |
tree | 88ba3c8298ed60a5969ce56f7eb3984e0028e6ff | |
parent | f38bdef90367a0beb9074bbaa4d5fa384660f7a8 (diff) | |
download | puppet-357afbbc6054dcdc7a1fd5ae468a2e86a44a9bde.tar.gz puppet-357afbbc6054dcdc7a1fd5ae468a2e86a44a9bde.tar.xz puppet-357afbbc6054dcdc7a1fd5ae468a2e86a44a9bde.zip |
removed type.method() syntax, and replaced it with Type { default => value} syntax -- i still need to add test cases
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@409 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet.rb | 6 | ||||
-rw-r--r-- | lib/puppet/transportable.rb | 28 | ||||
-rw-r--r-- | lib/puppet/type/component.rb | 3 | ||||
-rw-r--r-- | lib/puppet/type/pfile.rb | 8 |
4 files changed, 31 insertions, 14 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb index 6a49338f3..415bd253b 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -15,6 +15,12 @@ require 'puppet/log' # # it's also a place to find top-level commands like 'debug' module Puppet + class Error < RuntimeError + attr_accessor :stack + end + + class DevError < Error; end + # the hash that determines how our system behaves @@config = Hash.new(false) diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb index 0c12a432d..5cfe3d045 100644 --- a/lib/puppet/transportable.rb +++ b/lib/puppet/transportable.rb @@ -51,14 +51,7 @@ module Puppet def to_type retobj = nil if type = Puppet::Type.type(self.type) - begin - # this will fail if the type already exists - # which may or may not be a good thing... - retobj = type.new(self) - rescue => detail - err "Failed to create %s: %s" % [type.name,detail] - return nil - end + retobj = type.new(self) else raise "Could not find object type %s" % self.type end @@ -162,6 +155,10 @@ module Puppet # exists in our scope # this assumes that type/name combinations are globally # unique + + # XXX this still might be wrong, because it doesn't search + # up scopes + # either that, or it's redundant name = [child[:name],child.type].join("--") if nametable.include?(name) @@ -176,7 +173,20 @@ module Puppet } else # the object does not exist yet in our scope # now we have the object instantiated, in our scope - object = child.to_type + begin + object = child.to_type + rescue Puppet::Error => except + Puppet.err "Failed to create %s: %s" % + [child.type,except.message] + if Puppet[:debug] + puts except.stack + end + next + rescue => except + Puppet.err "Failed to create %s %s: %s" % + [child.type,child.inspect,except.message] + next + end nametable[name] = object # this sets the order of the object diff --git a/lib/puppet/type/component.rb b/lib/puppet/type/component.rb index cba4ea9d4..0e9ae5c20 100644 --- a/lib/puppet/type/component.rb +++ b/lib/puppet/type/component.rb @@ -63,7 +63,8 @@ Component ary.each { |child| unless child.is_a?(Puppet::Element) debug "Got object of type %s" % child.class - raise "Containers can only contain Puppet::Elements" + raise "Containers can only contain Puppet::Elements, not %s" % + child.class end @children.push child child.parent = self diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index 1db63f8fd..d6c0dbdf2 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -117,7 +117,7 @@ module Puppet # off an event if we detect a change def sync if @is.nil? - err "@is is nil" + Puppet.err "@is is nil" end if self.updatesum # set the @should value to the new @is value @@ -267,7 +267,7 @@ module Puppet end unless self.parent.stat - err "PFile '%s' does not exist; cannot chown" % + Puppet.err "PFile '%s' does not exist; cannot chown" % self.parent[:path] end @@ -318,7 +318,7 @@ module Puppet end unless self.parent.stat - err "PFile '%s' does not exist; cannot chmod" % + Puppet.err "PFile '%s' does not exist; cannot chmod" % self.parent[:path] return end @@ -415,7 +415,7 @@ module Puppet end unless self.parent.stat - err "PFile '%s' does not exist; cannot chgrp" % + Puppet.err "PFile '%s' does not exist; cannot chgrp" % self.parent[:path] return end |