~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: INADA Naoki
  • Date: 2011-05-05 09:15:34 UTC
  • mto: (5830.3.3 i18n-msgfmt)
  • mto: This revision was merged to the branch mainline in revision 5873.
  • Revision ID: songofacandy@gmail.com-20110505091534-7sv835xpofwrmpt4
Add update-pot command to Makefile and tools/bzrgettext script that
extracts help text from bzr commands.

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
59
 
        details.  (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 details.
 
59
    (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
 
        "the commit builder.")
 
307
        "record_entry_contents.")
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
1715
1715
 
1716
1716
class InvalidHttpResponse(TransportError):
1717
1717
 
1718
 
    _fmt = "Invalid http response for %(path)s: %(msg)s%(orig_error)s"
 
1718
    _fmt = "Invalid http response for %(path)s: %(msg)s"
1719
1719
 
1720
1720
    def __init__(self, path, msg, orig_error=None):
1721
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,)
1728
1722
        TransportError.__init__(self, msg, orig_error=orig_error)
1729
1723
 
1730
1724
 
1737
1731
        InvalidHttpResponse.__init__(self, path, msg)
1738
1732
 
1739
1733
 
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
 
 
1753
1734
class InvalidHttpContentType(InvalidHttpResponse):
1754
1735
 
1755
1736
    _fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1783
1764
    _fmt = "Working tree has conflicts."
1784
1765
 
1785
1766
 
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
 
 
1795
1767
class ParseConfigError(BzrError):
1796
1768
 
1797
 
    _fmt = "Error(s) parsing config file %(filename)s:\n%(errors)s"
1798
 
 
1799
1769
    def __init__(self, errors, filename):
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)
 
1770
        if filename is None:
 
1771
            filename = ""
 
1772
        message = "Error(s) parsing config file %s:\n%s" % \
 
1773
            (filename, ('\n'.join(e.msg for e in errors)))
 
1774
        BzrError.__init__(self, message)
1811
1775
 
1812
1776
 
1813
1777
class NoEmailInUsername(BzrError):
1821
1785
 
1822
1786
class SigningFailed(BzrError):
1823
1787
 
1824
 
    _fmt = 'Failed to GPG sign data with command "%(command_line)s"'
 
1788
    _fmt = 'Failed to gpg sign data with command "%(command_line)s"'
1825
1789
 
1826
1790
    def __init__(self, command_line):
1827
1791
        BzrError.__init__(self, command_line=command_line)
1828
1792
 
1829
1793
 
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
 
 
1854
1794
class WorkingTreeNotRevision(BzrError):
1855
1795
 
1856
1796
    _fmt = ("The working tree for %(basedir)s has changed since"
2109
2049
    _fmt = "Parameter %(param)s contains a newline."
2110
2050
 
2111
2051
 
 
2052
class DependencyNotPresent(BzrError):
 
2053
 
 
2054
    _fmt = 'Unable to import library "%(library)s": %(error)s'
 
2055
 
 
2056
    def __init__(self, library, error):
 
2057
        BzrError.__init__(self, library=library, error=error)
 
2058
 
 
2059
 
2112
2060
class ParamikoNotPresent(DependencyNotPresent):
2113
2061
 
2114
2062
    _fmt = "Unable to import paramiko (required for sftp support): %(error)s"
2717
2665
 
2718
2666
    This is distinct from ErrorFromSmartServer so that it is possible to
2719
2667
    distinguish between the following two cases:
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.
 
2668
      - ErrorFromSmartServer was uncaught.  This is logic error in the client
 
2669
        and so should provoke a traceback to the user.
 
2670
      - ErrorFromSmartServer was caught but its error_tuple could not be
 
2671
        translated.  This is probably because the server sent us garbage, and
 
2672
        should not provoke a traceback.
2726
2673
    """
2727
2674
 
2728
2675
    _fmt = "Server sent an unexpected error: %(error_tuple)r"
3127
3074
    _fmt = "Shelf corrupt."
3128
3075
 
3129
3076
 
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
 
 
3142
3077
class NoSuchShelfId(BzrError):
3143
3078
 
3144
3079
    _fmt = 'No changes are shelved with id "%(shelf_id)d".'
3314
3249
    def __init__(self, name, string):
3315
3250
        self.name = name
3316
3251
        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