Class: Spackle::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/spackle/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message) {|_self| ... } ⇒ Error

Returns a new instance of Error.

Yields:

  • (_self)

Yield Parameters:



12
13
14
15
16
# File 'lib/spackle/error.rb', line 12

def initialize(message)
  @message = message
  @backtrace = []
  yield self if block_given?
end

Instance Attribute Details

#backtraceObject (readonly)

Returns the value of attribute backtrace.



10
11
12
# File 'lib/spackle/error.rb', line 10

def backtrace
  @backtrace
end

#messageObject (readonly)

Returns the value of attribute message.



10
11
12
# File 'lib/spackle/error.rb', line 10

def message
  @message
end

Instance Method Details

#add_error(error_or_file, line = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/spackle/error.rb', line 18

def add_error(error_or_file, line = nil)
  case error_or_file
  when Error
    @backtrace << error_or_file
  when String
    @backtrace << BacktraceEntry.new(error_or_file, line)
  else
    raise ArgumentError.new("unrecognized error input '#{error_or_file}'. Should be a filename or a Spackle::BacktraceEntry")
  end
end