Django Migration error handling

I need to understand how to efficiently log and handle any errors that I get from running the command -

 python manage.py migrate

I am trying to write some tests for my shell script that runs the migrate command, but the moment I try running it on a migration file that is purposed to fail, the entire python code crashes without logging that error, even if there is a try catch block present.

Are you using call_command() to launch the command? A snippet showing what you’re trying would help.