##// END OF EJS Templates
errors: make exit codes class variables instead...
Martin von Zweigbergk -
r48085:73f52278 default
parent child Browse files
Show More
@@ -54,14 +54,13 b' class Hint(object):'
54 54 class Error(Hint, Exception):
55 55 """Base class for Mercurial errors."""
56 56
57 def __init__(
58 self, message, hint=None, coarse_exit_code=None, detailed_exit_code=None
59 ):
57 coarse_exit_code = None
58 detailed_exit_code = None
59
60 def __init__(self, message, hint=None):
60 61 # type: (bytes, Optional[bytes]) -> None
61 62 self.message = message
62 63 self.hint = hint
63 self.coarse_exit_code = coarse_exit_code
64 self.detailed_exit_code = detailed_exit_code
65 64 # Pass the message into the Exception constructor to help extensions
66 65 # that look for exc.args[0].
67 66 Exception.__init__(self, message)
@@ -97,10 +96,7 b' class StorageError(Error):'
97 96 Usually subclassed by a storage-specific exception.
98 97 """
99 98
100 def __init__(self, message, hint=None):
101 super(StorageError, self).__init__(
102 message, hint=hint, detailed_exit_code=50
103 )
99 detailed_exit_code = 50
104 100
105 101
106 102 class RevlogError(StorageError):
@@ -205,10 +201,8 b' class WorkerError(Exception):'
205 201 class InterventionRequired(Abort):
206 202 """Exception raised when a command requires human intervention."""
207 203
208 def __init__(self, message, hint=None):
209 super(InterventionRequired, self).__init__(
210 message, hint=hint, coarse_exit_code=1, detailed_exit_code=240
211 )
204 coarse_exit_code = 1
205 detailed_exit_code = 240
212 206
213 207 def format(self):
214 208 # type: () -> bytes
@@ -243,10 +237,7 b' class InputError(Abort):'
243 237 Examples: Invalid command, invalid flags, invalid revision.
244 238 """
245 239
246 def __init__(self, message, hint=None):
247 super(InputError, self).__init__(
248 message, hint=hint, detailed_exit_code=10
249 )
240 detailed_exit_code = 10
250 241
251 242
252 243 class StateError(Abort):
@@ -255,10 +246,7 b' class StateError(Abort):'
255 246 Examples: Unresolved merge conflicts, unfinished operations.
256 247 """
257 248
258 def __init__(self, message, hint=None):
259 super(StateError, self).__init__(
260 message, hint=hint, detailed_exit_code=20
261 )
249 detailed_exit_code = 20
262 250
263 251
264 252 class CanceledError(Abort):
@@ -267,10 +255,7 b' class CanceledError(Abort):'
267 255 Examples: Close commit editor with error status, quit chistedit.
268 256 """
269 257
270 def __init__(self, message, hint=None):
271 super(CanceledError, self).__init__(
272 message, hint=hint, detailed_exit_code=250
273 )
258 detailed_exit_code = 250
274 259
275 260
276 261 class SecurityError(Abort):
@@ -280,10 +265,7 b' class SecurityError(Abort):'
280 265 filesystem, mismatched GPG signature, DoS protection.
281 266 """
282 267
283 def __init__(self, message, hint=None):
284 super(SecurityError, self).__init__(
285 message, hint=hint, detailed_exit_code=150
286 )
268 detailed_exit_code = 150
287 269
288 270
289 271 class HookLoadError(Abort):
@@ -297,20 +279,17 b' class HookAbort(Abort):'
297 279
298 280 Exists to allow more specialized catching."""
299 281
300 def __init__(self, message, hint=None):
301 super(HookAbort, self).__init__(
302 message, hint=hint, detailed_exit_code=40
303 )
282 detailed_exit_code = 40
304 283
305 284
306 285 class ConfigError(Abort):
307 286 """Exception raised when parsing config files"""
308 287
288 detailed_exit_code = 30
289
309 290 def __init__(self, message, location=None, hint=None):
310 291 # type: (bytes, Optional[bytes], Optional[bytes]) -> None
311 super(ConfigError, self).__init__(
312 message, hint=hint, detailed_exit_code=30
313 )
292 super(ConfigError, self).__init__(message, hint=hint)
314 293 self.location = location
315 294
316 295 def format(self):
@@ -357,10 +336,7 b' class ResponseExpected(Abort):'
357 336 class RemoteError(Abort):
358 337 """Exception raised when interacting with a remote repo fails"""
359 338
360 def __init__(self, message, hint=None):
361 super(RemoteError, self).__init__(
362 message, hint=hint, detailed_exit_code=100
363 )
339 detailed_exit_code = 100
364 340
365 341
366 342 class OutOfBandError(RemoteError):
@@ -380,11 +356,11 b' class OutOfBandError(RemoteError):'
380 356 class ParseError(Abort):
381 357 """Raised when parsing config files and {rev,file}sets (msg[, pos])"""
382 358
359 detailed_exit_code = 10
360
383 361 def __init__(self, message, location=None, hint=None):
384 362 # type: (bytes, Optional[Union[bytes, int]], Optional[bytes]) -> None
385 super(ParseError, self).__init__(
386 message, hint=hint, detailed_exit_code=10
387 )
363 super(ParseError, self).__init__(message, hint=hint)
388 364 self.location = location
389 365
390 366 def format(self):
General Comments 0
You need to be logged in to leave comments. Login now