Fixed #18387 -- Do not call sys.exit during call_command.

Moved sys.exit(1) so as failing management commands reach it
only when running from command line.
This commit is contained in:
Claude Paroz 2012-05-26 20:50:44 +02:00
parent 4423757c0c
commit f2b6763ad7
7 changed files with 56 additions and 44 deletions

View file

@ -317,8 +317,12 @@ Exception class indicating a problem while executing a management
command.
If this exception is raised during the execution of a management
command, it will be caught and turned into a nicely-printed error
message to the appropriate output stream (i.e., stderr); as a
result, raising this exception (with a sensible description of the
command from a command line console, it will be caught and turned into a
nicely-printed error message to the appropriate output stream (i.e., stderr);
as a result, raising this exception (with a sensible description of the
error) is the preferred way to indicate that something has gone
wrong in the execution of a command.
If a management command is called from code through
:ref:`call_command <call-command>`, it's up to you to catch the exception
when needed.