Sha256: 60ddf7b86ea4efd5ce5e9ab818053cdef2cd263d47efe873619b14cc64bbef0b

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

module Puppet
  # The base class for all Puppet errors. It can wrap another exception
  class Error < RuntimeError
    attr_reader :original
    def initialize(message, original=nil)
      super(message)
      @original = original
    end
  end

  module ExternalFileError
    # This module implements logging with a filename and line number. Use this
    # for errors that need to report a location in a non-ruby file that we
    # parse.
    attr_accessor :line, :file

    def initialize(message, file=nil, line=nil, original=nil)
      super(message, original)
      @file = file
      @line = line
    end

    def to_s
      msg = super
      if @file and @line
        "#{msg} at #{@file}:#{@line}"
      elsif @line
        "#{msg} at line #{@line}"
      elsif @file
        "#{msg} in #{@file}"
      else
        msg
      end
    end
  end

  class ParseError < Puppet::Error
    include ExternalFileError
  end

  class ResourceError < Puppet::Error
    include ExternalFileError
  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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/lib/puppet/error.rb
puppet-3.1.1 lib/puppet/error.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/lib/puppet/error.rb
puppet-3.1.0 lib/puppet/error.rb
puppet-3.1.0.rc2 lib/puppet/error.rb
puppet-3.1.0.rc1 lib/puppet/error.rb