From 68c9c8930038fe3af3092f3de75591146d57c9e4 Mon Sep 17 00:00:00 2001 From: Ed Leafe Date: Tue, 18 Jan 2011 21:00:28 -0500 Subject: Completed first pass at converting all localized strings with multiple format substitutions. --- nova/exception.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'nova/exception.py') diff --git a/nova/exception.py b/nova/exception.py index ecd814e5d..2320e2214 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -33,8 +33,9 @@ class ProcessExecutionError(IOError): description = _("Unexpected error while running command.") if exit_code is None: exit_code = '-' - message = _("%s\nCommand: %s\nExit code: %s\nStdout: %r\nStderr: %r")\ - % (description, cmd, exit_code, stdout, stderr) + message = _("%(description)s\nCommand: %(cmd)s\n" + "Exit code: %(exit_code)s\nStdout: %(stdout)r\n" + "Stderr: %(stderr)r") % locals() IOError.__init__(self, message) -- cgit From 9bdcc71733105a49636f74a99130112ef96d0bce Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 21 Jan 2011 15:48:10 -0800 Subject: wrap sqlalchemy exceptions in a generic error --- nova/exception.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'nova/exception.py') diff --git a/nova/exception.py b/nova/exception.py index ecd814e5d..f36ffaee1 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -80,6 +80,24 @@ class TimeoutException(Error): pass +class DBError(Error): + """Wraps an implementation specific exception""" + def __init__(self, inner_exception): + self.inner_exception = inner_exception + super(DBError, self).__init__(str(inner_exception)) + + +def wrap_db_error(f): + def _wrap(*args, **kwargs): + try: + return f(*args, **kwargs) + except Exception, e: + LOG.exception(_('DB exception wrapped')) + raise DBError(e) + return _wrap + _wrap.func_name = f.func_name + + def wrap_exception(f): def _wrap(*args, **kw): try: -- cgit From 9c35a9a32dc58cb56685292a7ba056f95e715474 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 27 Jan 2011 10:48:00 -0800 Subject: Fixes NotFound messages in api to show the ec2_id. Added InstanceNotFound and VolumeNotFound errors to store internal id. Removed redundant method instance_get_by_id. Caught exceptions in api layer and fixed messages to use ec2_id. --- nova/exception.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'nova/exception.py') diff --git a/nova/exception.py b/nova/exception.py index f604fd63a..7d65bd6a5 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -46,7 +46,6 @@ class Error(Exception): class ApiError(Error): - def __init__(self, message='Unknown', code='Unknown'): self.message = message self.code = code @@ -57,6 +56,18 @@ class NotFound(Error): pass +class InstanceNotFound(NotFound): + def __init__(self, message, instance_id): + self.instance_id = instance_id + super(InstanceNotFound, self).__init__(message) + + +class VolumeNotFound(NotFound): + def __init__(self, message, volume_id): + self.volume_id = volume_id + super(VolumeNotFound, self).__init__(message) + + class Duplicate(Error): pass -- cgit