|InfoPath Developer Reference|
Version Added: InfoPath 2003
An Error object contains information about an InfoPath error, including its detailed message, short message, code, type, and the XML node that is associated with it.
The Errors collection is a full-featured collection—it provides properties and methods for adding, deleting, and gaining access to the Error objects that it contains.
In addition to managing the errors generated by InfoPath, the Errors collection can also be used to create custom errors using the Add method.
For more information about using the Errors collection, see Handling errors.
The Errors collection is accessed through the Errors property of the XDocument object. The Errors collection is associated with a form's underlying XML document so that when an error occurs, it occurs within the XML document.
In the following example, the Count property of the Errors collection is used get the count of errors currently contained in the collection:
To delete a specific error from the Errors collection, use the Delete method, passing the XML code and condition name as arguments:
To delete all of the errors in the Errors collection, use the DeleteAll method:
To set a reference to an error within the Errors collection, use the Item property: