Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/gitdb/exc.py: 81%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

16 statements  

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: https://opensource.org/license/bsd-3-clause/ 

5"""Module with common exceptions""" 

6from gitdb.util import to_hex_sha 

7 

8__all__ = [ 

9 'AmbiguousObjectName', 

10 'BadName', 

11 'BadObject', 

12 'BadObjectType', 

13 'InvalidDBRoot', 

14 'ODBError', 

15 'ParseError', 

16 'UnsupportedOperation', 

17 'to_hex_sha', 

18] 

19 

20class ODBError(Exception): 

21 """All errors thrown by the object database""" 

22 

23 

24class InvalidDBRoot(ODBError): 

25 """Thrown if an object database cannot be initialized at the given path""" 

26 

27 

28class BadObject(ODBError): 

29 """The object with the given SHA does not exist. Instantiate with the 

30 failed sha""" 

31 

32 def __str__(self): 

33 return "BadObject: %s" % to_hex_sha(self.args[0]) 

34 

35 

36class BadName(ODBError): 

37 """A name provided to rev_parse wasn't understood""" 

38 

39 def __str__(self): 

40 return "Ref '%s' did not resolve to an object" % self.args[0] 

41 

42 

43class ParseError(ODBError): 

44 """Thrown if the parsing of a file failed due to an invalid format""" 

45 

46 

47class AmbiguousObjectName(ODBError): 

48 """Thrown if a possibly shortened name does not uniquely represent a single object 

49 in the database""" 

50 

51 

52class BadObjectType(ODBError): 

53 """The object had an unsupported type""" 

54 

55 

56class UnsupportedOperation(ODBError): 

57 """Thrown if the given operation cannot be supported by the object database"""