apply_patch exit on error