66from commitizen import bump , factory , git , out
77from commitizen .commands .changelog import Changelog
88from commitizen .config import BaseConfig
9- from commitizen .error_codes import (
10- COMMIT_FAILED ,
11- NO_COMMITS_FOUND ,
12- NO_PATTERN_MAP ,
13- NO_VERSION_SPECIFIED ,
14- TAG_FAILED ,
9+ from commitizen .exceptions import (
10+ CommitFailedError ,
11+ NoCommitsFoundError ,
12+ NoPatternMapError ,
13+ NoVersionSpecifiedError ,
14+ TagFailedError ,
1515)
1616
1717
@@ -57,7 +57,7 @@ def find_increment(self, commits: List[git.GitCommit]) -> Optional[str]:
5757 bump_map = self .cz .bump_map
5858 if not bump_map or not bump_pattern :
5959 out .error (f"'{ self .config .settings ['name' ]} ' rule does not support bump" )
60- raise SystemExit ( NO_PATTERN_MAP )
60+ raise NoPatternMapError ( )
6161 increment = bump .find_increment (
6262 commits , regex = bump_pattern , increments_map = bump_map
6363 )
@@ -73,7 +73,7 @@ def __call__(self): # noqa: C901
7373 "Check if current version is specified in config file, like:\n "
7474 "version = 0.4.3\n "
7575 )
76- raise SystemExit ( NO_VERSION_SPECIFIED )
76+ raise NoVersionSpecifiedError ( )
7777
7878 # Initialize values from sources (conf)
7979 current_version : str = self .config .settings ["version" ]
@@ -102,7 +102,7 @@ def __call__(self): # noqa: C901
102102 # Unless we previously had a prerelease.
103103 if not commits and not current_version_instance .is_prerelease :
104104 out .error ("[NO_COMMITS_FOUND]\n " "No new commits found." )
105- raise SystemExit ( NO_COMMITS_FOUND )
105+ raise NoCommitsFoundError ( )
106106
107107 if increment is None :
108108 increment = self .find_increment (commits )
@@ -155,11 +155,11 @@ def __call__(self): # noqa: C901
155155 c = git .commit (message , args = self ._get_commit_args ())
156156 if c .err :
157157 out .error ('git.commit error: "{}"' .format (c .err .strip ()))
158- raise SystemExit ( COMMIT_FAILED )
158+ raise CommitFailedError ( )
159159 c = git .tag (new_tag_version )
160160 if c .err :
161161 out .error (c .err )
162- raise SystemExit ( TAG_FAILED )
162+ raise TagFailedError ( )
163163 out .success ("Done!" )
164164
165165 def _get_commit_args (self ):
0 commit comments