Show More
@@ -1,114 +1,116 | |||
|
1 | 1 | # error.py - Mercurial exceptions |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005-2008 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | """Mercurial exceptions. |
|
9 | 9 | |
|
10 | 10 | This allows us to catch exceptions at higher levels without forcing |
|
11 | 11 | imports. |
|
12 | 12 | """ |
|
13 | 13 | |
|
14 | 14 | # Do not import anything here, please |
|
15 | 15 | |
|
16 | 16 | class RevlogError(Exception): |
|
17 | 17 | pass |
|
18 | 18 | |
|
19 | 19 | class LookupError(RevlogError, KeyError): |
|
20 | 20 | def __init__(self, name, index, message): |
|
21 | 21 | self.name = name |
|
22 | 22 | if isinstance(name, str) and len(name) == 20: |
|
23 | 23 | from node import short |
|
24 | 24 | name = short(name) |
|
25 | 25 | RevlogError.__init__(self, '%s@%s: %s' % (index, name, message)) |
|
26 | 26 | |
|
27 | 27 | def __str__(self): |
|
28 | 28 | return RevlogError.__str__(self) |
|
29 | 29 | |
|
30 | 30 | class ManifestLookupError(LookupError): |
|
31 | 31 | pass |
|
32 | 32 | |
|
33 | 33 | class CommandError(Exception): |
|
34 | 34 | """Exception raised on errors in parsing the command line.""" |
|
35 | 35 | |
|
36 | 36 | class InterventionRequired(Exception): |
|
37 | 37 | """Exception raised when a command requires human intervention.""" |
|
38 | 38 | |
|
39 | 39 | class Abort(Exception): |
|
40 | 40 | """Raised if a command needs to print an error and exit.""" |
|
41 | 41 | def __init__(self, *args, **kw): |
|
42 | 42 | Exception.__init__(self, *args) |
|
43 | 43 | self.hint = kw.get('hint') |
|
44 | 44 | |
|
45 | 45 | class ConfigError(Abort): |
|
46 | 46 | 'Exception raised when parsing config files' |
|
47 | 47 | |
|
48 | 48 | class OutOfBandError(Exception): |
|
49 | 49 | 'Exception raised when a remote repo reports failure' |
|
50 | 50 | |
|
51 | 51 | class ParseError(Exception): |
|
52 | 52 | 'Exception raised when parsing config files (msg[, pos])' |
|
53 | 53 | |
|
54 | 54 | class RepoError(Exception): |
|
55 | 55 | def __init__(self, *args, **kw): |
|
56 | 56 | Exception.__init__(self, *args) |
|
57 | 57 | self.hint = kw.get('hint') |
|
58 | 58 | |
|
59 | 59 | class RepoLookupError(RepoError): |
|
60 | 60 | pass |
|
61 | 61 | |
|
62 | 62 | class CapabilityError(RepoError): |
|
63 | 63 | pass |
|
64 | 64 | |
|
65 | 65 | class RequirementError(RepoError): |
|
66 | 66 | """Exception raised if .hg/requires has an unknown entry.""" |
|
67 | 67 | pass |
|
68 | 68 | |
|
69 | 69 | class LockError(IOError): |
|
70 | 70 | def __init__(self, errno, strerror, filename, desc): |
|
71 | 71 | IOError.__init__(self, errno, strerror, filename) |
|
72 | 72 | self.desc = desc |
|
73 | 73 | |
|
74 | 74 | class LockHeld(LockError): |
|
75 | 75 | def __init__(self, errno, filename, desc, locker): |
|
76 | 76 | LockError.__init__(self, errno, 'Lock held', filename, desc) |
|
77 | 77 | self.locker = locker |
|
78 | 78 | |
|
79 | 79 | class LockUnavailable(LockError): |
|
80 | 80 | pass |
|
81 | 81 | |
|
82 | 82 | class ResponseError(Exception): |
|
83 | 83 | """Raised to print an error with part of output and exit.""" |
|
84 | 84 | |
|
85 | 85 | class UnknownCommand(Exception): |
|
86 | 86 | """Exception raised if command is not in the command table.""" |
|
87 | 87 | |
|
88 | 88 | class AmbiguousCommand(Exception): |
|
89 | 89 | """Exception raised if command shortcut matches more than one command.""" |
|
90 | 90 | |
|
91 | 91 | # derived from KeyboardInterrupt to simplify some breakout code |
|
92 | 92 | class SignalInterrupt(KeyboardInterrupt): |
|
93 | 93 | """Exception raised on SIGTERM and SIGHUP.""" |
|
94 | 94 | |
|
95 | 95 | class SignatureError(Exception): |
|
96 | 96 | pass |
|
97 | 97 | |
|
98 | 98 | class PushRaced(RuntimeError): |
|
99 | 99 | """An exception raised during unbundling that indicate a push race""" |
|
100 | 100 | |
|
101 | 101 | # bundle2 related errors |
|
102 | 102 | class BundleValueError(ValueError): |
|
103 | """error raised when bundle2 cannot be processed | |
|
104 | ||
|
105 | Current main usecase is unsupported part types.""" | |
|
103 | """error raised when bundle2 cannot be processed""" | |
|
106 | 104 | |
|
107 | def __init__(self, parttype): | |
|
105 | def __init__(self, parttype, params=()): | |
|
108 | 106 | self.parttype = parttype |
|
109 | super(BundleValueError, self).__init__(parttype) | |
|
107 | self.params = params | |
|
108 | msg = parttype | |
|
109 | if self.params: | |
|
110 | msg = '%s - %s' % (msg, ', '.join(self.params)) | |
|
111 | super(BundleValueError, self).__init__(msg) | |
|
110 | 112 | |
|
111 | 113 | class ReadOnlyPartError(RuntimeError): |
|
112 | 114 | """error raised when code tries to alter a part being generated""" |
|
113 | 115 | pass |
|
114 | 116 |
General Comments 0
You need to be logged in to leave comments.
Login now