Move error checking function to Python module.