catch more error cases and trigger rebuild

@tfoote @wjwwood Please review.