~tr3buchet/nova/lock

« back to all changes in this revision

Viewing changes to nova/exception.py

  • Committer: Vishvananda Ishaya
  • Date: 2010-12-22 20:59:53 UTC
  • mto: This revision was merged to the branch mainline in revision 482.
  • Revision ID: vishvananda@gmail.com-20101222205953-j2j5t0qjwlcd0t2s
merge trunk and upgrade to cheetah templating

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
 
29
29
class ProcessExecutionError(IOError):
 
30
 
30
31
    def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
31
32
                 description=None):
32
33
        if description is None:
33
 
            description = "Unexpected error while running command."
 
34
            description = _("Unexpected error while running command.")
34
35
        if exit_code is None:
35
36
            exit_code = '-'
36
 
        message = "%s\nCommand: %s\nExit code: %s\nStdout: %r\nStderr: %r" % (
37
 
                  description, cmd, exit_code, stdout, stderr)
 
37
        message = _("%s\nCommand: %s\nExit code: %s\nStdout: %r\nStderr: %r")\
 
38
                % (description, cmd, exit_code, stdout, stderr)
38
39
        IOError.__init__(self, message)
39
40
 
40
41
 
41
42
class Error(Exception):
 
43
 
42
44
    def __init__(self, message=None):
43
45
        super(Error, self).__init__(message)
44
46
 
45
47
 
46
48
class ApiError(Error):
 
49
 
47
50
    def __init__(self, message='Unknown', code='Unknown'):
48
51
        self.message = message
49
52
        self.code = code
81
84
        except Exception, e:
82
85
            if not isinstance(e, Error):
83
86
                #exc_type, exc_value, exc_traceback = sys.exc_info()
84
 
                logging.exception('Uncaught exception')
 
87
                logging.exception(_('Uncaught exception'))
85
88
                #logging.error(traceback.extract_stack(exc_traceback))
86
89
                raise Error(str(e))
87
90
            raise