eggs/mercurial-1.7.3-py2.6-linux-x86_64.egg/mercurial/error.py
changeset 69 c6bca38c1cbf
equal deleted inserted replaced
68:5ff1fc726848 69:c6bca38c1cbf
       
     1 # error.py - Mercurial exceptions
       
     2 #
       
     3 # Copyright 2005-2008 Matt Mackall <mpm@selenic.com>
       
     4 #
       
     5 # This software may be used and distributed according to the terms of the
       
     6 # GNU General Public License version 2 or any later version.
       
     7 
       
     8 """Mercurial exceptions.
       
     9 
       
    10 This allows us to catch exceptions at higher levels without forcing
       
    11 imports.
       
    12 """
       
    13 
       
    14 # Do not import anything here, please
       
    15 
       
    16 class RevlogError(Exception):
       
    17     pass
       
    18 
       
    19 class LookupError(RevlogError, KeyError):
       
    20     def __init__(self, name, index, message):
       
    21         self.name = name
       
    22         if isinstance(name, str) and len(name) == 20:
       
    23             from node import short
       
    24             name = short(name)
       
    25         RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))
       
    26 
       
    27     def __str__(self):
       
    28         return RevlogError.__str__(self)
       
    29 
       
    30 class CommandError(Exception):
       
    31     """Exception raised on errors in parsing the command line."""
       
    32 
       
    33 class Abort(Exception):
       
    34     """Raised if a command needs to print an error and exit."""
       
    35     def __init__(self, *args, **kw):
       
    36         Exception.__init__(self, *args)
       
    37         self.hint = kw.get('hint')
       
    38 
       
    39 class ConfigError(Abort):
       
    40     'Exception raised when parsing config files'
       
    41 
       
    42 class ParseError(Exception):
       
    43     'Exception raised when parsing config files (msg[, pos])'
       
    44 
       
    45 class RepoError(Exception):
       
    46     pass
       
    47 
       
    48 class RepoLookupError(RepoError):
       
    49     pass
       
    50 
       
    51 class CapabilityError(RepoError):
       
    52     pass
       
    53 
       
    54 class LockError(IOError):
       
    55     def __init__(self, errno, strerror, filename, desc):
       
    56         IOError.__init__(self, errno, strerror, filename)
       
    57         self.desc = desc
       
    58 
       
    59 class LockHeld(LockError):
       
    60     def __init__(self, errno, filename, desc, locker):
       
    61         LockError.__init__(self, errno, 'Lock held', filename, desc)
       
    62         self.locker = locker
       
    63 
       
    64 class LockUnavailable(LockError):
       
    65     pass
       
    66 
       
    67 class ResponseError(Exception):
       
    68     """Raised to print an error with part of output and exit."""
       
    69 
       
    70 class UnknownCommand(Exception):
       
    71     """Exception raised if command is not in the command table."""
       
    72 
       
    73 class AmbiguousCommand(Exception):
       
    74     """Exception raised if command shortcut matches more than one command."""
       
    75 
       
    76 # derived from KeyboardInterrupt to simplify some breakout code
       
    77 class SignalInterrupt(KeyboardInterrupt):
       
    78     """Exception raised on SIGTERM and SIGHUP."""
       
    79 
       
    80 class SignatureError(Exception):
       
    81     pass