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, #to_s, #unmarshall, #unmarshall_buffer

Constructor Details

#initialize(error_name, description = nil) ⇒ ErrorMessage

Returns a new instance of ErrorMessage.



247
248
249
250
251
252
253
# File 'lib/dbus/message.rb', line 247

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



255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/dbus/message.rb', line 255

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