The framework uses exceptions, run-time checks and tracing to detect problems during execution.
The framework mostly issues common .NET exceptions like ArgumentNullException and InvalidOperationException. This kind of exception usually indicates that there is an error in the code and therefore it does not make sense to catch and handle those other than by clearing up and trying to terminate properly. Other exceptions indicate that an operation is currently not possible because of internal or external constraints. For example, a shape might not be able to move because it is connected to another shape or a file cannot be opened because another application accesses it.In these cases only the current operation fails but the application is still in a healthy state and may continue. This type of exception is always derived from DiagrammingException, which indicates that it makes sense to catch it and either display it to the user or try to handle it programmatically.
When extending the framework by providing shape or model object classes, the above rules should be followed.Note that there are special framework methods to create the standard .NET exceptions ArgumentException, ArgumentNullException, ArgumentOutOfRangeException, InvalidOperationException and others. These methods make it easier to offer good exception messages, they support localization and they trace all exceptions, which is also a very important point. These methods are members of the DiagrammingExceptions class.
Extensive run-time checks are provided to detect bugs both in the framework itself and in framework extensions like shape and model object libraries. Run-time checks are implemented using Debug.Assert and Debug.Fail, which means they are compiled and executed only if the DEBUG symbol is defined. Extensions must call DiagrammingTrace.Assert and DiagrammingTrace.Fail for their own run-time checks. By this, they also profit from the customizing options described below.
All traces within the framework and its extensions go to the static DiagrammingTrace class. By default these traces are processed using the .NET tracing mechanism. This means traces can be configured via the application's configuration file. See the .NET documentation on tracing for more information.
Calls to the DiagrammingTrace class are delegated to an object implementing the ITrace interface. By default this object is of class DefaultTrace, which uses the .NET tracing mechanism. An application can however set a different implementation to the DiagrammingTrace class and thereby customize the behavior completely.