Exception: Squixtures::SquixtureError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/squixtures/exceptions.rb

Overview

This class provides the exception class used by the Squixtures library.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, cause = nil, verbose = true) ⇒ SquixtureError

Constructor for the SquixtureError class.

Parameters

message

The message to be associated with the error.

cause

Any underlying exception to be associated with the error. Defaults to nil.



18
19
20
21
22
# File 'lib/squixtures/exceptions.rb', line 18

def initialize(message, cause=nil, verbose=true)
   super(message)
   @cause   = cause
   @verbose = verbose
end

Instance Attribute Details

#verboseObject

Attribute accessor/mutator declarations.



10
11
12
# File 'lib/squixtures/exceptions.rb', line 10

def verbose
  @verbose
end

Instance Method Details

#to_sObject

This method fetches a stringified interpretation of an exception.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/squixtures/exceptions.rb', line 25

def to_s()
   text = StringIO.new
   text << super
   if @verbose
      text << "\n" + self.backtrace.join("\n")
      if !@cause.nil?
         text << "\n\nCause: #{@cause}"
         text << "\n" + @cause.backtrace.join("\n")
      end
   end
   text.string
end