PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/mercurial/error.py

https://bitbucket.org/parren/hg-discovery
Python | 85 lines | 44 code | 21 blank | 20 comment | 2 complexity | 6bd64a9bd0ff0fb9216602873e15c2c9 MD5 | raw file
Possible License(s): GPL-2.0
  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. """Mercurial exceptions.
  8. This allows us to catch exceptions at higher levels without forcing
  9. imports.
  10. """
  11. # Do not import anything here, please
  12. class RevlogError(Exception):
  13. pass
  14. class LookupError(RevlogError, KeyError):
  15. def __init__(self, name, index, message):
  16. self.name = name
  17. if isinstance(name, str) and len(name) == 20:
  18. from node import short
  19. name = short(name)
  20. RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))
  21. def __str__(self):
  22. return RevlogError.__str__(self)
  23. class CommandError(Exception):
  24. """Exception raised on errors in parsing the command line."""
  25. class Abort(Exception):
  26. """Raised if a command needs to print an error and exit."""
  27. def __init__(self, *args, **kw):
  28. Exception.__init__(self, *args)
  29. self.hint = kw.get('hint')
  30. class ConfigError(Abort):
  31. 'Exception raised when parsing config files'
  32. class ParseError(Exception):
  33. 'Exception raised when parsing config files (msg[, pos])'
  34. class RepoError(Exception):
  35. pass
  36. class RepoLookupError(RepoError):
  37. pass
  38. class CapabilityError(RepoError):
  39. pass
  40. class RequirementError(RepoError):
  41. """Exception raised if .hg/requires has an unknown entry."""
  42. pass
  43. class LockError(IOError):
  44. def __init__(self, errno, strerror, filename, desc):
  45. IOError.__init__(self, errno, strerror, filename)
  46. self.desc = desc
  47. class LockHeld(LockError):
  48. def __init__(self, errno, filename, desc, locker):
  49. LockError.__init__(self, errno, 'Lock held', filename, desc)
  50. self.locker = locker
  51. class LockUnavailable(LockError):
  52. pass
  53. class ResponseError(Exception):
  54. """Raised to print an error with part of output and exit."""
  55. class UnknownCommand(Exception):
  56. """Exception raised if command is not in the command table."""
  57. class AmbiguousCommand(Exception):
  58. """Exception raised if command shortcut matches more than one command."""
  59. # derived from KeyboardInterrupt to simplify some breakout code
  60. class SignalInterrupt(KeyboardInterrupt):
  61. """Exception raised on SIGTERM and SIGHUP."""
  62. class SignatureError(Exception):
  63. pass