mercurial/error.py
author Matt Mackall <mpm@selenic.com>
Mon, 12 Jan 2009 10:42:31 -0600
changeset 7637 1d54e2f6c0b7
parent 7636 e3f8c6d6b72e
child 7640 7197812e8d44
permissions -rw-r--r--
error: move repo errors rename NoCapability to CapabilityError
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7633
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     1
"""
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     2
error.py - Mercurial exceptions
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     3
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     4
This allows us to catch exceptions at higher levels without forcing imports
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     5
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     6
Copyright 2005-2008 Matt Mackall <mpm@selenic.com>
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     7
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     8
This software may be used and distributed according to the terms
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     9
of the GNU General Public License, incorporated herein by reference.
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    10
"""
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    11
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    12
# Do not import anything here, please
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    13
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    14
class RevlogError(Exception):
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    15
    pass
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    16
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    17
class LookupError(RevlogError, KeyError):
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    18
    def __init__(self, name, index, message):
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    19
        self.name = name
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    20
        if isinstance(name, str) and len(name) == 20:
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    21
            from node import short
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    22
            name = short(name)
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    23
        RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    24
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    25
    def __str__(self):
08cabecfa8a8 errors: move revlog errors
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    26
        return RevlogError.__str__(self)
7636
e3f8c6d6b72e error: move ParseError
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
    27
e3f8c6d6b72e error: move ParseError
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
    28
class ParseError(Exception):
e3f8c6d6b72e error: move ParseError
Matt Mackall <mpm@selenic.com>
parents: 7633
diff changeset
    29
    """Exception raised on errors in parsing the command line."""
7637
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7636
diff changeset
    30
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7636
diff changeset
    31
class RepoError(Exception):
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7636
diff changeset
    32
    pass
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7636
diff changeset
    33
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7636
diff changeset
    34
class CapabilityError(RepoError):
1d54e2f6c0b7 error: move repo errors
Matt Mackall <mpm@selenic.com>
parents: 7636
diff changeset
    35
    pass