Exception: Emissary::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/emissary/errors.rb

Direct Known Subclasses

NetworkEncapsulatedError, TrackingError

Defined Under Namespace

Classes: ConnectionError, InvalidMessageFormat, NotImplementedError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(origin = Exception, message = '') ⇒ Error

Returns a new instance of Error.



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/emissary/errors.rb', line 45

def initialize(origin = Exception, message = '')
  
  case origin
    when Exception
      @origin = origin
    when Class
      @origin = origin.new message
    else
      @origin = Exception.new message
  end

  super message
end

Instance Attribute Details

#originObject (readonly)

Returns the value of attribute origin.



23
24
25
# File 'lib/emissary/errors.rb', line 23

def origin
  @origin
end

Class Method Details

.new(*args) ⇒ Object

:nodoc:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/emissary/errors.rb', line 25

def self.new(*args) #:nodoc:
  allocate.instance_eval(<<-EOS, __FILE__, __LINE__)
    alias :original_instance_of? :instance_of?
    alias :original_kind_of? :kind_of?
  
    def instance_of? klass
      self.original_instance_of? klass or origin.instance_of? klass
    end

    def kind_of? klass
      self.original_kind_of? klass or origin.kind_of? klass
    end

    # Call a superclass's #initialize if it has one
    initialize(*args)

    self
  EOS
end

Instance Method Details

#messageObject



67
68
69
70
# File 'lib/emissary/errors.rb', line 67

def message
  "#{super}\n\t#{self.backtrace.join("\n\t")}\n" +
  "Origin: #{origin.class}: #{origin_message}\n\t#{origin_backtrace.join("\n\t")}"
end

#origin_backtraceObject



59
60
61
# File 'lib/emissary/errors.rb', line 59

def origin_backtrace
  origin.backtrace
end

#origin_messageObject



63
64
65
# File 'lib/emissary/errors.rb', line 63

def origin_message
  origin.message
end