better handling of error when build.sh exits with non-zero exit status