summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util/errors.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/util/errors.rb')
-rw-r--r--lib/puppet/util/errors.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/puppet/util/errors.rb b/lib/puppet/util/errors.rb
index badba595c..0d2f2da9f 100644
--- a/lib/puppet/util/errors.rb
+++ b/lib/puppet/util/errors.rb
@@ -17,6 +17,18 @@ module Puppet::Util::Errors
return error
end
+ def error_context
+ if file and line
+ " at #{file}:#{line}"
+ elsif line
+ " at line #{line}"
+ elsif file
+ " in #{file}"
+ else
+ ""
+ end
+ end
+
# Wrap a call in such a way that we always throw the right exception and keep
# as much context as possible.
def exceptwrap(options = {})