ICriticalError Interface

Identifies an exception as a critical error. Critical errors indicate an unrecoverable error that should terminate an application immediately; therefore they should never be caught.

public interface ICriticalError

Remarks

Exceptions implementing this interface will be recognized as critical errors by the Exception.IsCriticalError method.

While using an empty interface as a marker is usually considered bad practice, in this case it is the best alternative, because:

  • an attribute to mark exception classes as critical would make checking a lot more expensive, as the type of every exception (and of its causing exceptions) should be checked for the presence of the attribute;
  • a CriticalException base class would be straightforward to check for, but would make it hard (if at all possible) to mark exceptions in existing code bases as critical, as they could be part of existing class hierarchies that have to be preserved.