miracle2k / django-assets

Django webassets integration.
BSD 2-Clause "Simplified" License
89 stars 79 forks source link

Ensure errors from build script are raised #29

Closed wyattanderson closed 10 years ago

wyattanderson commented 10 years ago

The webassets script will return a numeric error value in certain failure cases (such as FilterErrors raised by some filters) instead of raising an exception. Since run_with_argv is called directly here, we need to check its return value and raise a Django CommandError if the build command indicated a failure.

miracle2k commented 10 years ago

We shouldn't ignore the return value as is the case now, but I wonder, is raising a CommandError the correct (only?) way to determine the exit code of a Django command? Otherwise, it might be nicer to just set the exit code as desired.

wyattanderson commented 10 years ago

Yeah, it's sub-optimal, but as far as I can tell from reading the relevant Django source code, there's no way to raise a CommandError with an exit code other than 1.

It does seem that raising a CommandError is the right way to indicate failure in a management command, so I'm hesitant to bypass that by calling sys.exit directly, which is the only way I can think of to preserve the return code.