Exceptions and Error Semantics

Sharp Runtime exception hierarchy, HResult values, causal exceptions and native translation differences.

ConceptsSource 6d429559

Hierarchy

The project provides a broad curated System exception hierarchy, including argument, I/O, networking, platform and implementation exceptions.

HResult and causes

Many specialized exceptions populate .NET-compatible HResult constants, and causal/inner errors use native exception pointers where supported. Recent remediation corrected derived exception values and network propagation.

Translation guidance

  • Catch the narrow exception only when recovery differs.
  • Preserve a causal exception when translating an OS/vendor failure.
  • Do not infer an exception type from prose if tests/code define a different contract.
  • NotImplemented and PlatformNotSupported are meaningful public boundaries, not generic failure buckets.

Native difference

There is no CLR stack or managed exception filter machinery. C++ destruction/RAII runs during unwinding, and exception-safety of owned resources remains essential.