improve error detection and messages in driver.py