Add error handling to runCommand functions.