~ubuntu-branches/ubuntu/raring/cinder/raring-updates

« back to all changes in this revision

Viewing changes to cinder/exception.py

Tags: upstream-2013.1~g2
ImportĀ upstreamĀ versionĀ 2013.1~g2

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
import webob.exc
28
28
 
 
29
from cinder import flags
 
30
from cinder.openstack.common import cfg
29
31
from cinder.openstack.common import log as logging
30
32
 
31
33
LOG = logging.getLogger(__name__)
32
34
 
 
35
exc_log_opts = [
 
36
    cfg.BoolOpt('fatal_exception_format_errors',
 
37
                default=False,
 
38
                help='make exception message format errors fatal'),
 
39
]
 
40
 
 
41
FLAGS = flags.FLAGS
 
42
FLAGS.register_opts(exc_log_opts)
 
43
 
33
44
 
34
45
class ConvertedException(webob.exc.WSGIHTTPException):
35
46
    def __init__(self, code=0, title="", explanation=""):
114
125
                LOG.exception(_('Exception in string format operation'))
115
126
                for name, value in kwargs.iteritems():
116
127
                    LOG.error("%s: %s" % (name, value))
117
 
                # at least get the core message out if something happened
118
 
                message = self.message
 
128
                if FLAGS.fatal_exception_format_errors:
 
129
                    raise e
 
130
                else:
 
131
                    # at least get the core message out if something happened
 
132
                    message = self.message
119
133
 
120
134
        super(CinderException, self).__init__(message)
121
135
 
300
314
    message = _("Host %(host)s could not be found.")
301
315
 
302
316
 
 
317
class SchedulerHostFilterNotFound(NotFound):
 
318
    message = _("Scheduler Host Filter %(filter_name)s could not be found.")
 
319
 
 
320
 
 
321
class SchedulerHostWeigherNotFound(NotFound):
 
322
    message = _("Scheduler Host Weigher %(weigher_name)s could not be found.")
 
323
 
 
324
 
303
325
class HostBinaryNotFound(NotFound):
304
326
    message = _("Could not find binary %(binary)s on host %(host)s.")
305
327
 
372
394
 
373
395
 
374
396
class VolumeTypeExists(Duplicate):
375
 
    message = _("Volume Type %(name)s already exists.")
 
397
    message = _("Volume Type %(id)s already exists.")
376
398
 
377
399
 
378
400
class MigrationError(CinderException):