Better error handling in build script