Class: DBus::ErrorMessage

Inherits:
Message
  • Object
show all
Defined in:
lib/dbus/message.rb

Constant Summary

Constants inherited from Message

Message::DESTINATION, Message::ENDIANNESS, Message::ENDIANNESS_CHAR, Message::ERROR, Message::ERROR_NAME, Message::INTERFACE, Message::INVALID, Message::MEMBER, Message::MESSAGE_SIGNATURE, Message::METHOD_CALL, Message::METHOD_RETURN, Message::NO_AUTO_START, Message::NO_REPLY_EXPECTED, Message::PATH, Message::REPLY_SERIAL, Message::RESERVED_PATH, Message::SENDER, Message::SIGNAL, Message::SIGNATURE, Message::TYPE_NAMES

Instance Attribute Summary

Attributes inherited from Message

#destination, #error_name, #interface, #member, #message_type, #params, #path, #protocol, #reply_serial, #sender, #serial, #signature

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Message

#add_param, #annotate_exception, error, #marshall, #message_type_s, method_return, #reply_to, #to_s, #unmarshall_buffer

Constructor Details

#initialize(error_name, description = nil) ⇒ ErrorMessage

Returns a new instance of ErrorMessage.



257
258
259
260
261
# File 'lib/dbus/message.rb', line 257

def initialize(error_name, description = nil)
  super(ERROR)
  @error_name = error_name
  add_param(Type::STRING, description) unless description.nil?
end

Class Method Details

.from_exception(exc) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/dbus/message.rb', line 263

def self.from_exception(exc)
  name = if exc.is_a? DBus::Error
           exc.name
         else
           "org.freedesktop.DBus.Error.Failed"
           # exc.class.to_s # RuntimeError is not a valid name, has no dot
         end
  description = exc.message
  msg = new(name, description)
  msg.add_param(DBus.type("as"), exc.backtrace)
  msg
end