author | Pierre-Yves.David@ens-lyon.org |
Fri, 13 Jul 2012 22:15:11 +0200 | |
changeset 17220 | bdac214a4705 |
parent 15017 | f4522df38c65 |
child 18855 | 50c922c1b514 |
permissions | -rw-r--r-- |
8226
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
1 |
# error.py - Mercurial exceptions |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
2 |
# |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
3 |
# Copyright 2005-2008 Matt Mackall <mpm@selenic.com> |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
4 |
# |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
5 |
# This software may be used and distributed according to the terms of the |
10263 | 6 |
# GNU General Public License version 2 or any later version. |
7633 | 7 |
|
8227
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
8 |
"""Mercurial exceptions. |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
9 |
|
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
10 |
This allows us to catch exceptions at higher levels without forcing |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
11 |
imports. |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
12 |
""" |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
13 |
|
7633 | 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) |
|
7636 | 29 |
|
11287
b901bb751999
error: change ParseError to CommandError
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
30 |
class CommandError(Exception): |
7636 | 31 |
"""Exception raised on errors in parsing the command line.""" |
7637 | 32 |
|
11288
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
33 |
class Abort(Exception): |
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
34 |
"""Raised if a command needs to print an error and exit.""" |
11574
6381fa7bfa53
Abort: add a hint argument, printed in the next line inside parenthesis
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11292
diff
changeset
|
35 |
def __init__(self, *args, **kw): |
6381fa7bfa53
Abort: add a hint argument, printed in the next line inside parenthesis
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11292
diff
changeset
|
36 |
Exception.__init__(self, *args) |
6381fa7bfa53
Abort: add a hint argument, printed in the next line inside parenthesis
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
11292
diff
changeset
|
37 |
self.hint = kw.get('hint') |
11288
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
38 |
|
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
39 |
class ConfigError(Abort): |
8144
fca54469480e
ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents:
7947
diff
changeset
|
40 |
'Exception raised when parsing config files' |
fca54469480e
ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents:
7947
diff
changeset
|
41 |
|
15017
f4522df38c65
wireproto: add out-of-band error class to allow remote repo to report errors
Andrew Pritchard <andrewp@fogcreek.com>
parents:
14761
diff
changeset
|
42 |
class OutOfBandError(Exception): |
f4522df38c65
wireproto: add out-of-band error class to allow remote repo to report errors
Andrew Pritchard <andrewp@fogcreek.com>
parents:
14761
diff
changeset
|
43 |
'Exception raised when a remote repo reports failure' |
f4522df38c65
wireproto: add out-of-band error class to allow remote repo to report errors
Andrew Pritchard <andrewp@fogcreek.com>
parents:
14761
diff
changeset
|
44 |
|
11292 | 45 |
class ParseError(Exception): |
11288
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
46 |
'Exception raised when parsing config files (msg[, pos])' |
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
47 |
|
7637 | 48 |
class RepoError(Exception): |
14761
1a9256cdf10f
error: Add a hint argument to RepoError
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13447
diff
changeset
|
49 |
def __init__(self, *args, **kw): |
1a9256cdf10f
error: Add a hint argument to RepoError
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13447
diff
changeset
|
50 |
Exception.__init__(self, *args) |
1a9256cdf10f
error: Add a hint argument to RepoError
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13447
diff
changeset
|
51 |
self.hint = kw.get('hint') |
7637 | 52 |
|
9423
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
53 |
class RepoLookupError(RepoError): |
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
54 |
pass |
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
55 |
|
7637 | 56 |
class CapabilityError(RepoError): |
57 |
pass |
|
7640 | 58 |
|
13447
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
59 |
class RequirementError(RepoError): |
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
60 |
"""Exception raised if .hg/requires has an unknown entry.""" |
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
61 |
pass |
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
62 |
|
7640 | 63 |
class LockError(IOError): |
64 |
def __init__(self, errno, strerror, filename, desc): |
|
65 |
IOError.__init__(self, errno, strerror, filename) |
|
66 |
self.desc = desc |
|
67 |
||
68 |
class LockHeld(LockError): |
|
69 |
def __init__(self, errno, filename, desc, locker): |
|
70 |
LockError.__init__(self, errno, 'Lock held', filename, desc) |
|
71 |
self.locker = locker |
|
72 |
||
73 |
class LockUnavailable(LockError): |
|
74 |
pass |
|
7641
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
75 |
|
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
76 |
class ResponseError(Exception): |
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
77 |
"""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
|
78 |
|
7643
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
79 |
class UnknownCommand(Exception): |
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
80 |
"""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
|
81 |
|
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
82 |
class AmbiguousCommand(Exception): |
9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
Matt Mackall <mpm@selenic.com>
parents:
7641
diff
changeset
|
83 |
"""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
|
84 |
|
7644
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
85 |
# derived from KeyboardInterrupt to simplify some breakout code |
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
86 |
class SignalInterrupt(KeyboardInterrupt): |
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
87 |
"""Exception raised on SIGTERM and SIGHUP.""" |
7646 | 88 |
|
89 |
class SignatureError(Exception): |
|
90 |
pass |