Skip to content

Commit a375783

Browse files
committed
Fix error when ctx is not defined on ClickExceptions
The error handling code for `ClickException` assumed that `ctx` is defined for the exception object, which is true for many of the subclasses, but not all. Check for `ctx` before assuming it exists.
1 parent 73be8fb commit a375783

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

djclick/adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def run_from_argv(self, argv):
7171
if exit_code:
7272
sys.exit(exit_code)
7373
except click.ClickException as e:
74-
if getattr(e.ctx, "traceback", False): # NOCOV
74+
if getattr(e, "ctx", False) and getattr(e.ctx, "traceback", False): # NOCOV
7575
raise
7676
e.show()
7777
sys.exit(e.exit_code)

0 commit comments

Comments
 (0)