author | Matt Mackall <mpm@selenic.com> |
Wed, 21 Jan 2009 14:14:56 -0600 | |
changeset 7676 | 43cfbb21f04d |
parent 7646 | e62a456b8dc5 |
child 7947 | a454eeb1b827 |
permissions | -rw-r--r-- |
7633 | 1 |
""" |
2 |
error.py - Mercurial exceptions |
|
3 |
||
4 |
This allows us to catch exceptions at higher levels without forcing imports |
|
5 |
||
6 |
Copyright 2005-2008 Matt Mackall <mpm@selenic.com> |
|
7 |
||
8 |
This software may be used and distributed according to the terms |
|
9 |
of the GNU General Public License, incorporated herein by reference. |
|
10 |
""" |
|
11 |
||
12 |
# Do not import anything here, please |
|
13 |
||
14 |
class RevlogError(Exception): |
|
15 |
pass |
|
16 |
||
17 |
class LookupError(RevlogError, KeyError): |
|
18 |
def __init__(self, name, index, message): |
|
19 |
self.name = name |
|
20 |
if isinstance(name, str) and len(name) == 20: |
|
21 |
from node import short |
|
22 |
name = short(name) |
|
23 |
RevlogError.__init__(self, '%s@%s: %s' % (index, name, message)) |
|
24 |
||
25 |
def __str__(self): |
|
26 |
return RevlogError.__str__(self) |
|
7636 | 27 |
|
28 |
class ParseError(Exception): |
|
29 |
"""Exception raised on errors in parsing the command line.""" |
|
7637 | 30 |
|
31 |
class RepoError(Exception): |
|
32 |
pass |
|
33 |
||
34 |
class CapabilityError(RepoError): |
|
35 |
pass |
|
7640 | 36 |
|
37 |
class LockError(IOError): |
|
38 |
def __init__(self, errno, strerror, filename, desc): |
|
39 |
IOError.__init__(self, errno, strerror, filename) |
|
40 |
self.desc = desc |
|
41 |
||
42 |
class LockHeld(LockError): |
|
43 |
def __init__(self, errno, filename, desc, locker): |
|
44 |
LockError.__init__(self, errno, 'Lock held', filename, desc) |
|
45 |
self.locker = locker |
|
46 |
||
47 |
class LockUnavailable(LockError): |
|
48 |
pass |
|
7641
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
49 |
|
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
50 |
class ResponseError(Exception): |
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
51 |
"""Raised to print an error with part of output and exit.""" |
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
52 |
|
7643
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
53 |
class UnknownCommand(Exception): |
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
54 |
"""Exception raised if command is not in the command table.""" |
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
55 |
|
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
56 |
class AmbiguousCommand(Exception): |
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
57 |
"""Exception raised if command shortcut matches more than one command.""" |
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
58 |
|
7644
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
59 |
# derived from KeyboardInterrupt to simplify some breakout code |
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
60 |
class SignalInterrupt(KeyboardInterrupt): |
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
61 |
"""Exception raised on SIGTERM and SIGHUP.""" |
7646 | 62 |
|
63 |
class SignatureError(Exception): |
|
64 |
pass |