6
6
from decli import cli
7
7
8
8
from commitizen import commands , config , out
9
- from commitizen .exceptions import CommitizenException
9
+ from commitizen .exceptions import CommitizenException , ExpectedExit , NoCommandFoundError
10
10
11
11
logger = logging .getLogger (__name__ )
12
12
data = {
242
242
243
243
244
244
def commitizen_excepthook (type , value , tracekback ):
245
- original_excepthook (type , value , tracekback )
246
245
if isinstance (value , CommitizenException ):
246
+ original_excepthook (type , value , None )
247
247
sys .exit (value .exit_code )
248
+ else :
249
+ original_excepthook (type , value , tracekback )
248
250
249
251
250
252
sys .excepthook = commitizen_excepthook
@@ -257,14 +259,14 @@ def main():
257
259
# Show help if no arg provided
258
260
if len (sys .argv ) == 1 :
259
261
parser .print_help (sys .stderr )
260
- raise SystemExit ()
262
+ raise ExpectedExit ()
261
263
262
264
# This is for the command required constraint in 2.0
263
265
try :
264
266
args = parser .parse_args ()
265
267
except TypeError :
266
268
out .error ("Command is required" )
267
- raise SystemExit ()
269
+ raise NoCommandFoundError ()
268
270
269
271
if args .name :
270
272
conf .update ({"name" : args .name })
@@ -297,4 +299,4 @@ def main():
297
299
args .func (conf , vars (args ))()
298
300
except AttributeError :
299
301
out .error ("Command is required" )
300
- raise SystemExit ()
302
+ raise NoCommandFoundError ()
0 commit comments