Class: Exception::DRoby

Inherits:
Object show all
Defined in:
lib/roby/distributed/protocol.rb

Overview

An intermediate representation of Exception objects suitable to be sent to our peers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, message) ⇒ DRoby

Returns a new instance of DRoby.



500
# File 'lib/roby/distributed/protocol.rb', line 500

def initialize(model, message); @model, @message = model, message end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



499
500
501
# File 'lib/roby/distributed/protocol.rb', line 499

def message
  @message
end

#modelObject (readonly)

Returns the value of attribute model.



499
500
501
# File 'lib/roby/distributed/protocol.rb', line 499

def model
  @model
end

Instance Method Details

#proxy(peer) ⇒ Object

Returns a local representation of the exception object self describes. If the real exception message is not available, it reuses the more-specific exception class which is available.



505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
# File 'lib/roby/distributed/protocol.rb', line 505

def proxy(peer)
    error_model = model.proxy(peer)
    error_model.exception(self.message)

rescue ArgumentError
    # try to get a less-specific error model which does allow a simple
    # message. In the worst case, we will fall back to Exception itself
    #
    # However, include the real model name in the message
    message = "#{self.message} (#{model.ancestors.first.first})"
    for model in error_model.ancestors
  next unless model.kind_of?(Class)
  begin
      return model.exception(message)
  rescue ArgumentError
  end
    end
end