Exception: Puppet::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/vendor/puppet/error.rb

Overview

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…

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, line = nil, file = nil) ⇒ Error

Returns a new instance of Error.



16
17
18
19
20
21
# File 'lib/vendor/puppet/error.rb', line 16

def initialize(message, line = nil, file = nil)
  @message = message

  @line = line if line
  @file = file if file
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



6
7
8
# File 'lib/vendor/puppet/error.rb', line 6

def file
  @file
end

#lineObject

Returns the value of attribute line.



6
7
8
# File 'lib/vendor/puppet/error.rb', line 6

def line
  @line
end

Instance Method Details

#backtraceObject



8
9
10
11
12
13
14
# File 'lib/vendor/puppet/error.rb', line 8

def backtrace
  if defined?(@backtrace)
    return @backtrace
  else
    return super
  end
end

#to_sObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vendor/puppet/error.rb', line 23

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