~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Patch Queue Manager
  • Date: 2011-10-09 13:52:06 UTC
  • mfrom: (6202.1.3 revno-revision)
  • Revision ID: pqm@pqm.ubuntu.com-20111009135206-t3utsln6mtzv9eut
(jelmer) Add a --revision argument to 'bzr revno'. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from bzrlib import (
21
21
    osutils,
22
22
    symbol_versioning,
 
23
    i18n,
 
24
    trace,
23
25
    )
 
26
from bzrlib.i18n import gettext
24
27
from bzrlib.patches import (
25
28
    MalformedHunkHeader,
26
29
    MalformedLine,
140
143
        """Return format string for this exception or None"""
141
144
        fmt = getattr(self, '_fmt', None)
142
145
        if fmt is not None:
143
 
            return fmt
 
146
            i18n.install()
 
147
            unicode_fmt = unicode(fmt) #_fmt strings should be ascii
 
148
            if type(fmt) == unicode:
 
149
                trace.mutter("Unicode strings in error.fmt are deprecated")
 
150
            return gettext(unicode_fmt)
144
151
        fmt = getattr(self, '__doc__', None)
145
152
        if fmt is not None:
146
153
            symbol_versioning.warn("%s uses its docstring as a format, "
621
628
 
622
629
    _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
623
630
 
624
 
    def __init__(self, url, extra):
 
631
    def __init__(self, url, extra=""):
625
632
        PathError.__init__(self, url, extra=extra)
626
633
 
627
634
 
1703
1710
    _fmt = "Connection closed: %(msg)s %(orig_error)s"
1704
1711
 
1705
1712
 
 
1713
class ConnectionTimeout(ConnectionError):
 
1714
 
 
1715
    _fmt = "Connection Timeout: %(msg)s%(orig_error)s"
 
1716
 
 
1717
 
1706
1718
class InvalidRange(TransportError):
1707
1719
 
1708
1720
    _fmt = "Invalid range access in %(path)s at %(offset)s: %(msg)s"
1802
1814
        self.errors = '\n'.join(e.msg for e in errors)
1803
1815
 
1804
1816
 
 
1817
class ConfigOptionValueError(BzrError):
 
1818
 
 
1819
    _fmt = """Bad value "%(value)s" for option "%(name)s"."""
 
1820
 
 
1821
    def __init__(self, name, value):
 
1822
        BzrError.__init__(self, name=name, value=value)
 
1823
 
 
1824
 
1805
1825
class NoEmailInUsername(BzrError):
1806
1826
 
1807
1827
    _fmt = "%(username)r does not seem to contain a reasonable email address"
2341
2361
    """
2342
2362
 
2343
2363
 
 
2364
class GhostTagsNotSupported(BzrError):
 
2365
 
 
2366
    _fmt = "Ghost tags not supported by format %(format)r."
 
2367
 
 
2368
    def __init__(self, format):
 
2369
        self.format = format
 
2370
 
 
2371
 
2344
2372
class BinaryFile(BzrError):
2345
2373
 
2346
2374
    _fmt = "File is binary but should be text."
2776
2804
    _fmt = "Container has multiple records with the same name: %(name)s"
2777
2805
 
2778
2806
    def __init__(self, name):
2779
 
        self.name = name
 
2807
        self.name = name.decode("utf-8")
2780
2808
 
2781
2809
 
2782
2810
class NoDestinationAddress(InternalBzrError):
3316
3344
    def __init__(self, source, target):
3317
3345
        self.source = source
3318
3346
        self.target = target
 
3347
 
 
3348
 
 
3349
class HpssVfsRequestNotAllowed(BzrError):
 
3350
 
 
3351
    _fmt = ("VFS requests over the smart server are not allowed. Encountered: "
 
3352
            "%(method)s, %(arguments)s.")
 
3353
 
 
3354
    def __init__(self, method, arguments):
 
3355
        self.method = method
 
3356
        self.arguments = arguments