Class: DBus::ErrorMessage

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

Constant Summary

Constants inherited from Message

Message::DESTINATION, 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::SENDER, Message::SIGNAL, Message::SIGNATURE

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, error, #marshall, method_return, #reply_to, #unmarshall, #unmarshall_buffer

Constructor Details

#initialize(error_name, description = nil) ⇒ ErrorMessage

Returns a new instance of ErrorMessage.



289
290
291
292
293
294
295
# File 'lib/dbus/message.rb', line 289

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

Class Method Details

.from_exception(ex) ⇒ Object



297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/dbus/message.rb', line 297

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