[XEND] Add more exceptions and error messages

signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
This commit is contained in:
Tom Wilkie committed 2007-04-25 16:11:20 +01:00
1 parent 2ecc034a6a
commit edb909c878
2 files changed
+125 -4

No files matched your search

+104 -4
View File
@@ -48,10 +48,6 @@ class PIFIsPhysical(XendError):
def __init__(self):
XendError.__init__(self, 'PIF is physical')
class VLANTagInvalid(XendError):
def __init__(self):
XendError.__init__(self, 'VLAN tag invalid')
class VmError(XendError):
"""Vm construction error."""
pass
@@ -62,7 +58,111 @@ class HVMRequired(VmError):
'HVM guest support is unavailable: is VT/AMD-V '
'supported by your CPU and enabled in your BIOS?')
class XendAPIError(XendError):
"""Extend this class for all error thrown by
autoplugged classes"""
def __init__(self):
XendError.__init__(self, 'XendAPI Error: You should never see this'
' message; this class need to be overidden')
def get_api_error(self):
return ['INTERNAL_ERROR', 'You should never see this message; '
'this method needs to be overidden']
class CreateUnspecifiedAttributeError(XendAPIError):
def __init__(self, attr_name, class_name):
XendAPIError.__init__(self)
self.attr_name = attr_name
self.class_name = class_name
def get_api_error(self):
return ['CREATE_UNSPECIFIED_ATTRIBUTE', self.attr_name,
self.class_name]
def __str__(self):
return "CREATE_UNSPECIFIED_ATTRIBUTE: %s, %s" % (self.attr_name,
self.class_name)
class UnmanagedNetworkError(XendAPIError):
def __init__(self, attr_name):
XendAPIError.__init__(self)
self.attr_name = attr_name
def get_api_error(self):
return ['UNMANAGED_NETWORK_ERROR', self.attr_name]
def __str__(self):
return "UNMANAGED_NETWORK_ERROR: %s" % self.attr_name
class UniqueNameError(XendAPIError):
def __init__(self, name, class_name):
XendAPIError.__init__(self)
self.name = name
self.class_name = class_name
def get_api_error(self):
return ['UNIQUE_NAME_ERROR', self.name, self.class_name]
def __str__(self):
return 'UNIQUE_NAME_ERROR: %s, %s' % (self.name, self.class_name)
class InvalidDeviceError(XendAPIError):
def __init__(self, dev):
XendAPIError.__init__(self)
self.dev = dev
def get_api_error(self):
return ['INVALID_DEVICE_ERROR', self.dev]
def __str__(self):
return 'INVALID_DEVICE_ERROR: %s' % self.dev
class DeviceExistsError(XendAPIError):
def __init__(self, dev):
XendAPIError.__init__(self)
self.dev = dev
def get_api_error(self):
return ['DEVICE_EXISTS_ERROR', self.dev]
def __str__(self):
return 'DEVICE_EXISTS_ERROR: %s' % self.dev
class InvalidHandleError(XendAPIError):
def __init__(self, klass, handle):
XendAPIError.__init__(self)
self.klass = klass
self.handle = handle
def get_api_error(self):
return ['HANDLE_INVALID', self.klass, self.handle]
def __str__(self):
return 'HANDLE_INVALID: %s %s' % (self.klass, self.handle)
class ImplementationError(XendAPIError):
def __init__(self, klass, func):
XendAPIError.__init__(self)
self.klass = klass
self.func = func
def get_api_error(self):
return ['IMPLEMENTATION_ERROR', self.klass, self.func]
def __str__(self):
return 'IMPLEMENTATION_ERROR: %s %s' % (self.klass, self.func)
class VLANTagInvalid(XendAPIError):
def __init__(self, vlan):
XendAPIError.__init__(self)
self.vlan = vlan
def get_api_error(self):
return ['VLAN_TAG_INVALID', self.vlan]
def __str__(self):
return 'VLAN_TAG_INVALID: %s' % self.vlan
XEND_ERROR_AUTHENTICATION_FAILED = ('ELUSER', 'Authentication Failed')
XEND_ERROR_SESSION_INVALID = ('EPERMDENIED', 'Session Invalid')
XEND_ERROR_DOMAIN_INVALID = ('EINVALIDDOMAIN', 'Domain Invalid')
+21
View File
@@ -67,3 +67,24 @@ msgstr "HVM guest support is unavailable: is VT/AMD-V supported by your CPU and
msgid "SESSION_NOT_REGISTERED"
msgstr "This session is not registered to receive events. You must call event.register before event.next. (Session handle is %(1)s.)"
msgid "CREATE_UNSPECIFIED_ATTRIBUTE"
msgstr "You need to specify %s when creating a new %s"
msgid "UNMANAGED_NETWORK_ERROR"
msgstr "Cannot change %s on an unmanaged network"
msgid "UNIQUE_NAME_ERROR"
msgstr "Name %s for class %s is not unique"
msgid "INVALID_DEVICE_ERROR"
msgstr "Invalid device %s"
msgid "DEVICE_EXISTS_ERROR"
msgstr "Device already exists %s"
msgid "IMPLEMENTATION_ERROR"
msgstr "Class %s does not implement %s"
msgid "VLAN_TAG_INVALID"
msgstr "VLAN tag invalid %s"
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.