/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Vincent Ladeuil
  • Date: 2011-11-24 15:48:29 UTC
  • mfrom: (6289 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6337.
  • Revision ID: v.ladeuil+lp@free.fr-20111124154829-avowjpsxdl8yp2vz
merge trunk resolving conflicts

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
 
1572
1579
            problem we can raise the original error (value from sys.exc_info())
1573
1580
        """
1574
1581
        BzrError.__init__(self)
 
1582
        self.context = context
1575
1583
        self.reload_occurred = reload_occurred
1576
1584
        self.exc_info = exc_info
1577
1585
        self.orig_error = exc_info[1]
1659
1667
 
1660
1668
    def __init__(self, exc_info):
1661
1669
        import traceback
 
1670
        # GZ 2010-08-10: Cycle with exc_tb/exc_info affects at least one test
1662
1671
        self.exc_type, self.exc_value, self.exc_tb = exc_info
1663
1672
        self.exc_info = exc_info
1664
1673
        traceback_strings = traceback.format_exception(
1703
1712
    _fmt = "Connection closed: %(msg)s %(orig_error)s"
1704
1713
 
1705
1714
 
 
1715
class ConnectionTimeout(ConnectionError):
 
1716
 
 
1717
    _fmt = "Connection Timeout: %(msg)s%(orig_error)s"
 
1718
 
 
1719
 
1706
1720
class InvalidRange(TransportError):
1707
1721
 
1708
1722
    _fmt = "Invalid range access in %(path)s at %(offset)s: %(msg)s"
1802
1816
        self.errors = '\n'.join(e.msg for e in errors)
1803
1817
 
1804
1818
 
 
1819
class ConfigOptionValueError(BzrError):
 
1820
 
 
1821
    _fmt = """Bad value "%(value)s" for option "%(name)s"."""
 
1822
 
 
1823
    def __init__(self, name, value):
 
1824
        BzrError.__init__(self, name=name, value=value)
 
1825
 
 
1826
 
1805
1827
class NoEmailInUsername(BzrError):
1806
1828
 
1807
1829
    _fmt = "%(username)r does not seem to contain a reasonable email address"
1964
1986
        self.prefix = prefix
1965
1987
 
1966
1988
 
1967
 
class MalformedTransform(BzrError):
 
1989
class MalformedTransform(InternalBzrError):
1968
1990
 
1969
1991
    _fmt = "Tree transform is malformed %(conflicts)r"
1970
1992
 
2341
2363
    """
2342
2364
 
2343
2365
 
 
2366
class GhostTagsNotSupported(BzrError):
 
2367
 
 
2368
    _fmt = "Ghost tags not supported by format %(format)r."
 
2369
 
 
2370
    def __init__(self, format):
 
2371
        self.format = format
 
2372
 
 
2373
 
2344
2374
class BinaryFile(BzrError):
2345
2375
 
2346
2376
    _fmt = "File is binary but should be text."
2776
2806
    _fmt = "Container has multiple records with the same name: %(name)s"
2777
2807
 
2778
2808
    def __init__(self, name):
2779
 
        self.name = name
 
2809
        self.name = name.decode("utf-8")
2780
2810
 
2781
2811
 
2782
2812
class NoDestinationAddress(InternalBzrError):
3316
3346
    def __init__(self, source, target):
3317
3347
        self.source = source
3318
3348
        self.target = target
 
3349
 
 
3350
 
 
3351
class HpssVfsRequestNotAllowed(BzrError):
 
3352
 
 
3353
    _fmt = ("VFS requests over the smart server are not allowed. Encountered: "
 
3354
            "%(method)s, %(arguments)s.")
 
3355
 
 
3356
    def __init__(self, method, arguments):
 
3357
        self.method = method
 
3358
        self.arguments = arguments
 
3359
 
 
3360
 
 
3361
class UnsupportedKindChange(BzrError):
 
3362
 
 
3363
    _fmt = ("Kind change from %(from_kind)s to %(to_kind)s for "
 
3364
            "%(path)s not supported by format %(format)r")
 
3365
 
 
3366
    def __init__(self, path, from_kind, to_kind, format):
 
3367
        self.path = path
 
3368
        self.from_kind = from_kind
 
3369
        self.to_kind = to_kind
 
3370
        self.format = format