You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3KB

  1. # Copyright (C) 2010, 2011 Sebastian Thiel (byronimo@gmail.com) and contributors
  2. #
  3. # This module is part of GitDB and is released under
  4. # the New BSD License: http://www.opensource.org/licenses/bsd-license.php
  5. """Module with common exceptions"""
  6. from gitdb.util import to_hex_sha
  7. class ODBError(Exception):
  8. """All errors thrown by the object database"""
  9. class InvalidDBRoot(ODBError):
  10. """Thrown if an object database cannot be initialized at the given path"""
  11. class BadObject(ODBError):
  12. """The object with the given SHA does not exist. Instantiate with the
  13. failed sha"""
  14. def __str__(self):
  15. return "BadObject: %s" % to_hex_sha(self.args[0])
  16. class BadName(ODBError):
  17. """A name provided to rev_parse wasn't understood"""
  18. def __str__(self):
  19. return "Ref '%s' did not resolve to an object" % self.args[0]
  20. class ParseError(ODBError):
  21. """Thrown if the parsing of a file failed due to an invalid format"""
  22. class AmbiguousObjectName(ODBError):
  23. """Thrown if a possibly shortened name does not uniquely represent a single object
  24. in the database"""
  25. class BadObjectType(ODBError):
  26. """The object had an unsupported type"""
  27. class UnsupportedOperation(ODBError):
  28. """Thrown if the given operation cannot be supported by the object database"""