~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Jelmer Vernooij
  • Date: 2011-10-10 12:47:25 UTC
  • mto: This revision was merged to the branch mainline in revision 6211.
  • Revision ID: jelmer@samba.org-20111010124725-dvg76fjsf3cqcxx1
Add ControlDirFormat.supports_transport.

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"
1737
1749
        InvalidHttpResponse.__init__(self, path, msg)
1738
1750
 
1739
1751
 
 
1752
class HttpBoundaryMissing(InvalidHttpResponse):
 
1753
    """A multipart response ends with no boundary marker.
 
1754
 
 
1755
    This is a special case caused by buggy proxies, described in
 
1756
    <https://bugs.launchpad.net/bzr/+bug/198646>.
 
1757
    """
 
1758
 
 
1759
    _fmt = "HTTP MIME Boundary missing for %(path)s: %(msg)s"
 
1760
 
 
1761
    def __init__(self, path, msg):
 
1762
        InvalidHttpResponse.__init__(self, path, msg)
 
1763
 
 
1764
 
1740
1765
class InvalidHttpContentType(InvalidHttpResponse):
1741
1766
 
1742
1767
    _fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1789
1814
        self.errors = '\n'.join(e.msg for e in errors)
1790
1815
 
1791
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
 
1792
1825
class NoEmailInUsername(BzrError):
1793
1826
 
1794
1827
    _fmt = "%(username)r does not seem to contain a reasonable email address"
2328
2361
    """
2329
2362
 
2330
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
 
2331
2372
class BinaryFile(BzrError):
2332
2373
 
2333
2374
    _fmt = "File is binary but should be text."
2763
2804
    _fmt = "Container has multiple records with the same name: %(name)s"
2764
2805
 
2765
2806
    def __init__(self, name):
2766
 
        self.name = name
 
2807
        self.name = name.decode("utf-8")
2767
2808
 
2768
2809
 
2769
2810
class NoDestinationAddress(InternalBzrError):
3303
3344
    def __init__(self, source, target):
3304
3345
        self.source = source
3305
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