/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-08-16 13:12:40 UTC
  • mfrom: (6071 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6076.
  • Revision ID: v.ladeuil+lp@free.fr-20110816131240-gcyn9cik86dxwgz3
Merge into trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
    Base class for errors raised by bzrlib.
55
55
 
56
56
    :cvar internal_error: if True this was probably caused by a bzr bug and
57
 
    should be displayed with a traceback; if False (or absent) this was
58
 
    probably a user or environment error and they don't need the gory details.
59
 
    (That can be overridden by -Derror on the command line.)
 
57
        should be displayed with a traceback; if False (or absent) this was
 
58
        probably a user or environment error and they don't need the gory
 
59
        details.  (That can be overridden by -Derror on the command line.)
60
60
 
61
61
    :cvar _fmt: Format string to display the error; this is expanded
62
 
    by the instance's dict.
 
62
        by the instance's dict.
63
63
    """
64
64
 
65
65
    internal_error = False
304
304
class RootMissing(InternalBzrError):
305
305
 
306
306
    _fmt = ("The root entry of a tree must be the first entry supplied to "
307
 
        "record_entry_contents.")
 
307
        "the commit builder.")
308
308
 
309
309
 
310
310
class NoPublicBranch(BzrError):
621
621
 
622
622
    _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
623
623
 
624
 
    def __init__(self, url, extra):
 
624
    def __init__(self, url, extra=""):
625
625
        PathError.__init__(self, url, extra=extra)
626
626
 
627
627
 
864
864
        """Construct a new AlreadyVersionedError.
865
865
 
866
866
        :param path: This is the path which is versioned,
867
 
        which should be in a user friendly form.
 
867
            which should be in a user friendly form.
868
868
        :param context_info: If given, this is information about the context,
869
 
        which could explain why this is expected to not be versioned.
 
869
            which could explain why this is expected to not be versioned.
870
870
        """
871
871
        BzrError.__init__(self)
872
872
        self.path = path
885
885
        """Construct a new NotVersionedError.
886
886
 
887
887
        :param path: This is the path which is not versioned,
888
 
        which should be in a user friendly form.
 
888
            which should be in a user friendly form.
889
889
        :param context_info: If given, this is information about the context,
890
 
        which could explain why this is expected to be versioned.
 
890
            which could explain why this is expected to be versioned.
891
891
        """
892
892
        BzrError.__init__(self)
893
893
        self.path = path
1140
1140
        BzrError.__init__(self, files=files, files_str=files_str)
1141
1141
 
1142
1142
 
 
1143
class ExcludesUnsupported(BzrError):
 
1144
 
 
1145
    _fmt = ('Excluding paths during commit is not supported by '
 
1146
            'repository at %(repository)r.')
 
1147
 
 
1148
    def __init__(self, repository):
 
1149
        BzrError.__init__(self, repository=repository)
 
1150
 
 
1151
 
1143
1152
class BadCommitMessageEncoding(BzrError):
1144
1153
 
1145
1154
    _fmt = 'The specified commit message contains characters unsupported by '\
1706
1715
 
1707
1716
class InvalidHttpResponse(TransportError):
1708
1717
 
1709
 
    _fmt = "Invalid http response for %(path)s: %(msg)s"
 
1718
    _fmt = "Invalid http response for %(path)s: %(msg)s%(orig_error)s"
1710
1719
 
1711
1720
    def __init__(self, path, msg, orig_error=None):
1712
1721
        self.path = path
 
1722
        if orig_error is None:
 
1723
            orig_error = ''
 
1724
        else:
 
1725
            # This is reached for obscure and unusual errors so we want to
 
1726
            # preserve as much info as possible to ease debug.
 
1727
            orig_error = ': %r' % (orig_error,)
1713
1728
        TransportError.__init__(self, msg, orig_error=orig_error)
1714
1729
 
1715
1730
 
1722
1737
        InvalidHttpResponse.__init__(self, path, msg)
1723
1738
 
1724
1739
 
 
1740
class HttpBoundaryMissing(InvalidHttpResponse):
 
1741
    """A multipart response ends with no boundary marker.
 
1742
 
 
1743
    This is a special case caused by buggy proxies, described in
 
1744
    <https://bugs.launchpad.net/bzr/+bug/198646>.
 
1745
    """
 
1746
 
 
1747
    _fmt = "HTTP MIME Boundary missing for %(path)s: %(msg)s"
 
1748
 
 
1749
    def __init__(self, path, msg):
 
1750
        InvalidHttpResponse.__init__(self, path, msg)
 
1751
 
 
1752
 
1725
1753
class InvalidHttpContentType(InvalidHttpResponse):
1726
1754
 
1727
1755
    _fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1755
1783
    _fmt = "Working tree has conflicts."
1756
1784
 
1757
1785
 
 
1786
class ConfigContentError(BzrError):
 
1787
 
 
1788
    _fmt = "Config file %(filename)s is not UTF-8 encoded\n"
 
1789
 
 
1790
    def __init__(self, filename):
 
1791
        BzrError.__init__(self)
 
1792
        self.filename = filename
 
1793
 
 
1794
 
1758
1795
class ParseConfigError(BzrError):
1759
1796
 
 
1797
    _fmt = "Error(s) parsing config file %(filename)s:\n%(errors)s"
 
1798
 
1760
1799
    def __init__(self, errors, filename):
1761
 
        if filename is None:
1762
 
            filename = ""
1763
 
        message = "Error(s) parsing config file %s:\n%s" % \
1764
 
            (filename, ('\n'.join(e.msg for e in errors)))
1765
 
        BzrError.__init__(self, message)
 
1800
        BzrError.__init__(self)
 
1801
        self.filename = filename
 
1802
        self.errors = '\n'.join(e.msg for e in errors)
 
1803
 
 
1804
 
 
1805
class ConfigOptionValueError(BzrError):
 
1806
 
 
1807
    _fmt = """Bad value "%(value)s" for option "%(name)s"."""
 
1808
 
 
1809
    def __init__(self, name, value):
 
1810
        BzrError.__init__(self, name=name, value=value)
1766
1811
 
1767
1812
 
1768
1813
class NoEmailInUsername(BzrError):
1776
1821
 
1777
1822
class SigningFailed(BzrError):
1778
1823
 
1779
 
    _fmt = 'Failed to gpg sign data with command "%(command_line)s"'
 
1824
    _fmt = 'Failed to GPG sign data with command "%(command_line)s"'
1780
1825
 
1781
1826
    def __init__(self, command_line):
1782
1827
        BzrError.__init__(self, command_line=command_line)
1783
1828
 
1784
1829
 
 
1830
class SignatureVerificationFailed(BzrError):
 
1831
 
 
1832
    _fmt = 'Failed to verify GPG signature data with error "%(error)s"'
 
1833
 
 
1834
    def __init__(self, error):
 
1835
        BzrError.__init__(self, error=error)
 
1836
 
 
1837
 
 
1838
class DependencyNotPresent(BzrError):
 
1839
 
 
1840
    _fmt = 'Unable to import library "%(library)s": %(error)s'
 
1841
 
 
1842
    def __init__(self, library, error):
 
1843
        BzrError.__init__(self, library=library, error=error)
 
1844
 
 
1845
 
 
1846
class GpgmeNotInstalled(DependencyNotPresent):
 
1847
 
 
1848
    _fmt = 'python-gpgme is not installed, it is needed to verify signatures'
 
1849
 
 
1850
    def __init__(self, error):
 
1851
        DependencyNotPresent.__init__(self, 'gpgme', error)
 
1852
 
 
1853
 
1785
1854
class WorkingTreeNotRevision(BzrError):
1786
1855
 
1787
1856
    _fmt = ("The working tree for %(basedir)s has changed since"
2040
2109
    _fmt = "Parameter %(param)s contains a newline."
2041
2110
 
2042
2111
 
2043
 
class DependencyNotPresent(BzrError):
2044
 
 
2045
 
    _fmt = 'Unable to import library "%(library)s": %(error)s'
2046
 
 
2047
 
    def __init__(self, library, error):
2048
 
        BzrError.__init__(self, library=library, error=error)
2049
 
 
2050
 
 
2051
2112
class ParamikoNotPresent(DependencyNotPresent):
2052
2113
 
2053
2114
    _fmt = "Unable to import paramiko (required for sftp support): %(error)s"
2656
2717
 
2657
2718
    This is distinct from ErrorFromSmartServer so that it is possible to
2658
2719
    distinguish between the following two cases:
2659
 
      - ErrorFromSmartServer was uncaught.  This is logic error in the client
2660
 
        and so should provoke a traceback to the user.
2661
 
      - ErrorFromSmartServer was caught but its error_tuple could not be
2662
 
        translated.  This is probably because the server sent us garbage, and
2663
 
        should not provoke a traceback.
 
2720
 
 
2721
    - ErrorFromSmartServer was uncaught.  This is logic error in the client
 
2722
      and so should provoke a traceback to the user.
 
2723
    - ErrorFromSmartServer was caught but its error_tuple could not be
 
2724
      translated.  This is probably because the server sent us garbage, and
 
2725
      should not provoke a traceback.
2664
2726
    """
2665
2727
 
2666
2728
    _fmt = "Server sent an unexpected error: %(error_tuple)r"
3065
3127
    _fmt = "Shelf corrupt."
3066
3128
 
3067
3129
 
 
3130
class DecompressCorruption(BzrError):
 
3131
 
 
3132
    _fmt = "Corruption while decompressing repository file%(orig_error)s"
 
3133
 
 
3134
    def __init__(self, orig_error=None):
 
3135
        if orig_error is not None:
 
3136
            self.orig_error = ", %s" % (orig_error,)
 
3137
        else:
 
3138
            self.orig_error = ""
 
3139
        BzrError.__init__(self)
 
3140
 
 
3141
 
3068
3142
class NoSuchShelfId(BzrError):
3069
3143
 
3070
3144
    _fmt = 'No changes are shelved with id "%(shelf_id)d".'
3221
3295
    def __init__(self, branch_url):
3222
3296
        self.branch_url = branch_url
3223
3297
 
 
3298
 
 
3299
# FIXME: I would prefer to define the config related exception classes in
 
3300
# config.py but the lazy import mechanism proscribes this -- vila 20101222
 
3301
class OptionExpansionLoop(BzrError):
 
3302
 
 
3303
    _fmt = 'Loop involving %(refs)r while expanding "%(string)s".'
 
3304
 
 
3305
    def __init__(self, string, refs):
 
3306
        self.string = string
 
3307
        self.refs = '->'.join(refs)
 
3308
 
 
3309
 
 
3310
class ExpandingUnknownOption(BzrError):
 
3311
 
 
3312
    _fmt = 'Option %(name)s is not defined while expanding "%(string)s".'
 
3313
 
 
3314
    def __init__(self, name, string):
 
3315
        self.name = name
 
3316
        self.string = string
 
3317
 
 
3318
 
 
3319
class NoCompatibleInter(BzrError):
 
3320
 
 
3321
    _fmt = ('No compatible object available for operations from %(source)r '
 
3322
            'to %(target)r.')
 
3323
 
 
3324
    def __init__(self, source, target):
 
3325
        self.source = source
 
3326
        self.target = target