libnm-core, settings: move NMSettingsError to nm-errors

Move the definition of NMSettingsError to nm-errors, register it with
D-Bus, and verify in the tests that it maps correctly.

Remove a few unused error codes, simplify a few others, and rename
GENERAL to FAILED and HOSTNAME_INVALID to INVALID_HOSTNAME, for
consistency.
This commit is contained in:
Dan Winship
2014-10-15 15:27:25 -04:00
parent 115f8bead8
commit 3be53899fa
14 changed files with 104 additions and 110 deletions

View File

@@ -990,6 +990,9 @@ class Connection(dbus.service.Object):
###################################################################
IFACE_SETTINGS = 'org.freedesktop.NetworkManager.Settings'
class InvalidHostnameException(dbus.DBusException):
_dbus_error_name = IFACE_SETTINGS + '.InvalidHostname'
class Settings(dbus.service.Object):
def __init__(self, bus, object_path):
dbus.service.Object.__init__(self, bus, object_path)
@@ -1032,6 +1035,14 @@ class Settings(dbus.service.Object):
self.props['Connections'] = dbus.Array(self.connections.keys(), 'o')
self.PropertiesChanged({ 'connections': self.props['Connections'] })
@dbus.service.method(dbus_interface=IFACE_SETTINGS, in_signature='s', out_signature='')
def SaveHostname(self, hostname):
# Arbitrary requirement to test error handling
if hostname.find('.') == -1:
raise InvalidHostnameException()
self.props['Hostname'] = hostname
self.PropertiesChanged({ 'hostname': hostname })
@dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='s', out_signature='a{sv}')
def GetAll(self, iface):
if iface != IFACE_SETTINGS: