mirror of
https://github.com/django/django.git
synced 2025-10-26 15:16:09 +00:00
Fixed #19923 -- Display tracebacks for non-CommandError exceptions
By default, show tracebacks for management command errors when the exception is not a CommandError. Thanks Jacob Radford for the report.
This commit is contained in:
@@ -241,7 +241,7 @@ class BaseCommand(object):
|
||||
except Exception as e:
|
||||
# self.stderr is not guaranteed to be set here
|
||||
stderr = getattr(self, 'stderr', OutputWrapper(sys.stderr, self.style.ERROR))
|
||||
if options.traceback:
|
||||
if options.traceback or not isinstance(e, CommandError):
|
||||
stderr.write(traceback.format_exc())
|
||||
else:
|
||||
stderr.write('%s: %s' % (e.__class__.__name__, e))
|
||||
|
||||
Reference in New Issue
Block a user