Improve error handling for use as a Jenkins test