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

Constructor Details

#initialize(error_name, description = nil) ⇒ ErrorMessage

Returns a new instance of ErrorMessage.



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

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(ex) ⇒ Object



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

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 = new(name, description)
  msg.add_param(DBus.type("as"), ex.backtrace)
  msg
end