ArcGIS Pro 2.9 API Reference Guide
MarkAsException Method
Example 

ArcGIS.Core.Data.Topology Namespace > Topology Class : MarkAsException Method
The topology error to be marked as an exception.
Marks the topology error specified by error as an exception. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public void MarkAsException( 
   TopologyError error
)
Public Sub MarkAsException( _
   ByVal error As TopologyError _
) 

Parameters

error
The topology error to be marked as an exception.
Exceptions
ExceptionDescription
error is null.
This operation cannot be invoked inside ArcGIS.Core.Data.Geodatabase.ApplyEdits or when an edit operation is in progress.
A geodatabase-related exception has occurred.
Remarks

Topology errors occur when topology rules are violated during the Validate operation. There will be instances when the occurrence of a defined error may be acceptable. For example, street lines cannot have dangles, i.e., they must be connected to another streets. However, a cul-de-sac or a road which is closed at one end is an exception. Once an error is marked as an exception, it remains that way until it is unmarked as an exception, resetting it as an error.

This operation generates its own editing transaction and therefore cannot be wrapped inside a separate transaction.

When writing an ArcGIS Pro add-in, the extension method ArcGIS.Core.Data.Extensions.ArcGISCoreDataExtensions.MarkAsExceptionInEditOperation should be used instead. This extension method will create an edit operation on the Pro undo/redo stack and redraw any affected layers.

Example
// Get all the errors due to features violating the "PointProperlyInsideArea" topology rule.

using (TopologyDefinition topologyDefinition = topology.GetDefinition())
{
  TopologyRule pointProperlyInsideAreaRule = topologyDefinition.GetRules().First(rule => rule.RuleType == TopologyRuleType.PointProperlyInsideArea);

  ErrorDescription errorDescription = new ErrorDescription(topology.GetExtent())
  {
    TopologyRule = pointProperlyInsideAreaRule
  };

  IReadOnlyList<TopologyError> errorsDueToViolatingPointProperlyInsideAreaRule = topology.GetErrors(errorDescription);
  Console.WriteLine($"There are {errorsDueToViolatingPointProperlyInsideAreaRule.Count} feature violating the 'PointProperlyInsideArea' topology rule.");

  // Mark all errors from features violating the 'PointProperlyInsideArea' topology rule as exceptions.

  foreach (TopologyError error in errorsDueToViolatingPointProperlyInsideAreaRule)
  {
    topology.MarkAsException(error);
  }

  // Now verify all the errors from features violating the 'PointProperlyInsideArea' topology rule have indeed been
  // marked as exceptions.
  //
  // By default, ErrorDescription is initialized to ErrorType.ErrorAndException.  Here we want ErrorType.ErrorOnly.

  errorDescription = new ErrorDescription(topology.GetExtent())
  {
    ErrorType = ErrorType.ErrorOnly,
    TopologyRule = pointProperlyInsideAreaRule
  };

  IReadOnlyList<TopologyError> errorsAfterMarkedAsExceptions = topology.GetErrors(errorDescription);
  Console.WriteLine($"There are {errorsAfterMarkedAsExceptions.Count} feature violating the 'PointProperlyInsideArea' topology rule after all the errors have been marked as exceptions.");

  // Finally, reset all the exceptions as errors by unmarking them as exceptions.

  foreach (TopologyError error in errorsDueToViolatingPointProperlyInsideAreaRule)
  {
    topology.UnmarkAsException(error);
  }

  IReadOnlyList<TopologyError> errorsAfterUnmarkedAsExceptions = topology.GetErrors(errorDescription);
  Console.WriteLine($"There are {errorsAfterUnmarkedAsExceptions.Count} feature violating the 'PointProperlyInsideArea' topology rule after all the exceptions have been reset as errors.");
}
Requirements

Target Platforms: Windows 11, Windows 10, Windows 8.1

See Also

Reference

Topology Class
Topology Members