summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/interpreter.rb
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2007-10-04 08:04:44 -0500
committerRick Bradley <rick@rickbradley.com>2007-10-04 08:04:44 -0500
commit92d23e0398ffbaf7e264bb7ff716bd6f83130b07 (patch)
treeaf4a9296a11733c4636a88d38925804ea6f0793d /lib/puppet/parser/interpreter.rb
parent1334b786ac622a6094ba68b3e66fce3f5841deed (diff)
parentbd8e38236a23ae687c418fcbb90e5f61c8c67b01 (diff)
downloadpuppet-92d23e0398ffbaf7e264bb7ff716bd6f83130b07.tar.gz
puppet-92d23e0398ffbaf7e264bb7ff716bd6f83130b07.tar.xz
puppet-92d23e0398ffbaf7e264bb7ff716bd6f83130b07.zip
Merge branch 'master' of git://reductivelabs.com/puppet into routing
Diffstat (limited to 'lib/puppet/parser/interpreter.rb')
-rw-r--r--lib/puppet/parser/interpreter.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index 81867c84b..0b8c035ba 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -25,7 +25,8 @@ class Puppet::Parser::Interpreter
# evaluate our whole tree
def compile(node)
- return Puppet::Parser::Compile.new(node, parser(node.environment), :ast_nodes => usenodes?).compile
+ raise Puppet::ParseError, "Could not parse configuration; cannot compile" unless env_parser = parser(node.environment)
+ return Puppet::Parser::Compile.new(node, env_parser, :ast_nodes => usenodes?).compile
end
# create our interpreter
@@ -74,15 +75,14 @@ class Puppet::Parser::Interpreter
parser.parse
return parser
rescue => detail
- if Puppet[:trace]
- puts detail.backtrace
- end
msg = "Could not parse"
if environment and environment != ""
msg += " for environment %s" % environment
end
- msg += ": %s" % detail
- raise Puppet::Error, detail
+ msg += ": %s" % detail.to_s
+ error = Puppet::Error.new(msg)
+ error.set_backtrace(detail.backtrace)
+ raise error
end
end
@@ -96,8 +96,11 @@ class Puppet::Parser::Interpreter
tmp = create_parser(environment)
@parsers[environment].clear if @parsers[environment]
@parsers[environment] = tmp
- rescue
- # Nothing, yo.
+ rescue => detail
+ # If a parser already exists, than assume that we logged the
+ # exception elsewhere and reuse the parser. If one doesn't
+ # exist, then reraise.
+ raise detail unless @parsers[environment]
end
end
@parsers[environment]