Doesn't the exception causes the document to invalid anyhow? 
If not, we can refactor this so we only set the values when no exception is thrown.