Exception: LogJam::LogJamError

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Constructor for the LogJamError class.

Parameters

message

The message to be associated with the error.

cause

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



20
21
22
23
24
# File 'lib/logjam/exceptions.rb', line 20

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

Instance Attribute Details

#verboseObject

Attribute accessor/mutator declarations.



12
13
14
# File 'lib/logjam/exceptions.rb', line 12

def verbose
  @verbose
end

Instance Method Details

#to_sObject

This method fetches a stringified interpretation of an exception.



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/logjam/exceptions.rb', line 27

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