Boris Johnson is warned he could face jail if he fails to comply with a new law designed to stop the UK leaving the EU with no deal.