diff options
Diffstat (limited to 'lib/puppet/error.rb')
-rw-r--r-- | lib/puppet/error.rb | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/lib/puppet/error.rb b/lib/puppet/error.rb index 7be84d573..d0a0c9cc5 100644 --- a/lib/puppet/error.rb +++ b/lib/puppet/error.rb @@ -1,43 +1,43 @@ module Puppet # :nodoc: - # The base class for all Puppet errors. We want to make it easy to add - # line and file information. This probably isn't necessary for all - # errors, but... - class Error < RuntimeError - attr_accessor :line, :file + # The base class for all Puppet errors. We want to make it easy to add + # line and file information. This probably isn't necessary for all + # errors, but... + class Error < RuntimeError + attr_accessor :line, :file - def backtrace - if defined?(@backtrace) - return @backtrace - else - return super - end - end + def backtrace + if defined?(@backtrace) + return @backtrace + else + return super + end + end - def initialize(message, line = nil, file = nil) - @message = message + def initialize(message, line = nil, file = nil) + @message = message - @line = line if line - @file = file if file - end + @line = line if line + @file = file if file + end - def to_s - str = nil - if self.file and self.line - str = "#{@message} at #{@file}:#{@line}" - elsif self.line - str = "#{@message} at line #{@line}" - elsif self.file - str = "#{@message} in #{self.file}" - else - str = @message.to_s - end + def to_s + str = nil + if self.file and self.line + str = "#{@message} at #{@file}:#{@line}" + elsif self.line + str = "#{@message} at line #{@line}" + elsif self.file + str = "#{@message} in #{self.file}" + else + str = @message.to_s + end - str - end + str end + end - # An error class for when I don't know what happened. Automatically - # prints a stack trace when in debug mode. - class DevError < Puppet::Error - end + # An error class for when I don't know what happened. Automatically + # prints a stack trace when in debug mode. + class DevError < Puppet::Error + end end |