fix detecting error exit code