Coverage for /Users/OORDCOR/Documents/code/bump-my-version/bumpversion/exceptions.py: 91%

22 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-15 09:15 -0600

1"""Custom exceptions for BumpVersion.""" 

2from typing import Optional 

3 

4from click import Context, UsageError 

5 

6 

7class BumpVersionError(UsageError): 

8 """Custom base class for all BumpVersion exception types.""" 

9 

10 def __init__(self, message: str, ctx: Optional[Context] = None): 

11 self.message = message 

12 self.ctx = ctx 

13 

14 

15class FormattingError(BumpVersionError): 

16 """We are unable to represent a version required by a format.""" 

17 

18 pass 

19 

20 

21class MissingValueError(BumpVersionError): 

22 """A part required for a version format is empty.""" 

23 

24 pass 

25 

26 

27class DirtyWorkingDirectoryError(BumpVersionError): 

28 """The working directory is dirty, and it is not allowed.""" 

29 

30 pass 

31 

32 

33class SignedTagsError(BumpVersionError): 

34 """The VCS does not support signed tags.""" 

35 

36 pass 

37 

38 

39class VersionNotFoundError(BumpVersionError): 

40 """A version number was not found in a source file.""" 

41 

42 pass 

43 

44 

45class InvalidVersionPartError(BumpVersionError): 

46 """The specified part (e.g. 'bugfix') was not found.""" 

47 

48 pass 

49 

50 

51class ConfigurationError(BumpVersionError): 

52 """A configuration key-value is missing or in the wrong type.""" 

53 

54 pass 

55 

56 

57class BadInputError(BumpVersionError): 

58 """User input was bad.""" 

59 

60 pass