TyphonException Hierarchy & Catalog
A single-rooted, typed exception tree with numeric codes, an
IsTransienthint, and a catalog of every concrete failure type.
Status: โ Implemented ยท Visibility: Public ยท Level: ๐ต Core ยท Category: Errors
๐ฏ What it solves
Database failures span wildly different recovery strategies โ a lock timeout wants a retry, a CRC mismatch wants an operator alert, a duplicate key wants a validation message back to the user. A flat Exception (or a grab-bag of unrelated custom types) forces every caller to either catch everything or maintain a brittle list of exact types. Typhon gives every failure a place in one typed tree, rooted at TyphonException, so application code can catch as broadly or narrowly as the situation calls for, and read a numeric ErrorCode plus an IsTransient hint without parsing message text.
โ๏ธ How it works (in brief)
TyphonException : Exception carries a TyphonErrorCode (numeric, grouped into per-subsystem ranges) and a virtual IsTransient (default false โ subclasses opt in). TyphonTimeoutException is an intermediate base so catch (TyphonTimeoutException) handles every kind of timeout uniformly; StorageException and DurabilityException are similar subsystem-grouping intermediates. Leaf types with no sibling in their category (UniqueConstraintViolationException, the schema exceptions, InvalidAccessException) sit directly under TyphonException โ no intermediate exists for a one-member group. The engine never retries on the caller's behalf: IsTransient is informational, and only the caller decides whether and how to retry.
๐ป Usage
try
{
using var tx = dbe.CreateQuickTransaction();
var e = tx.OpenMut(soldier);
var health = e.Read(Unit.Health);
health.Current -= 25;
e.Set(Unit.Health, health);
tx.Commit();
}
catch (LockTimeoutException ex)
{
// Narrowest: this specific failure โ ex.ResourceName, ex.WaitDuration
}
catch (TyphonTimeoutException ex)
{
// Mid: any timeout (lock, transaction, page-cache/WAL back-pressure)
}
catch (TyphonException ex)
{
// Broadest: any engine error
_logger.LogError(ex, "Operation failed: {ErrorCode} IsTransient={IsTransient}", ex.ErrorCode, ex.IsTransient);
throw;
}
Catalog of concrete types
| Type | Parent | IsTransient |
Notable typed properties |
|---|---|---|---|
TyphonTimeoutException |
TyphonException |
true |
WaitDuration |
LockTimeoutException, TransactionTimeoutException, PageCacheBackpressureTimeoutException, WalBackPressureTimeoutException |
TyphonTimeoutException |
true |
see Timeout Exceptions & Deadlines |
SnapshotExpiredException |
TyphonException |
false |
SnapshotTsn, RetainedMinTsn |
StorageException |
TyphonException |
false |
โ |
CorruptionException / PageCorruptionException |
StorageException |
false |
ComponentName, PageIndex / ExpectedCrc, ComputedCrc |
DatabaseLockedException |
StorageException |
false |
OwnerPid, OwnerMachine, StartedAt |
TransactionExceedsPageCacheException |
StorageException |
false |
HeldPages, CachePages, MarkedPages, PinnedPages |
DurabilityException |
TyphonException |
false |
โ |
WalWriteException, WalSegmentException, WalClaimTooLargeException |
DurabilityException |
false |
โ / SegmentPath / RequestedBytes, BufferCapacity |
CommitDurabilityUncertainException |
DurabilityException |
false |
HighLsn |
CommitPublishIncompleteException |
DurabilityException |
false |
HighLsn, Durable (committed in the WAL but not fully published; the engine stops committing โ reopen, do not re-run) |
BulkSessionAlreadyActiveException, BulkSessionClosedException, BulkLoadCheckpointTimeoutException |
DurabilityException |
false |
ActiveBulkSessionId / BulkSessionId / BulkSessionId, Timeout |
IndexRebuildTempCorruptException |
DurabilityException |
false |
Path, Offset, Check (an open's index rebuild read back a temp block that failed a check; the open fails and the next one rebuilds) |
BackupException |
DurabilityException |
false |
โ (base of every backup, restore and verify failure) |
BackupStoreLockedException, BackupStoreMismatchException, BackupPackCorruptException, BackupChainBrokenException, BackupFormatUnsupportedException, RestoreRefusedException, BackupAbortedException, BackupPlanChangedException, RestoreTargetUnreachableException, BackupArchiveDivergedException |
BackupException |
false, except BackupStoreLockedException (true) and BackupAbortedException (true for a CBW stall, gate timeout or WAL flush timeout) |
e.g. HolderPid/HolderMachine (store locked), PointId/MissingId/RestorableAlternatives (chain broken), Reason (restore refused / aborted / target unreachable) |
ResourceExhaustedException |
TyphonException |
true |
ResourcePath, ResourceType, CurrentUsage, Limit โ see Resource Exhaustion Handling |
TransactionSequenceExhaustedException |
ResourceExhaustedException |
false |
TSN space (48 bits) exhausted โ migrate to a fresh database |
SchemaValidationException, SchemaMigrationException, SchemaDowngradeException |
TyphonException |
false |
Diff / ComponentName, Failures / ComponentName, PersistedRevision, RuntimeRevision |
SchemaMismatchException |
TyphonException |
false |
Differences (an exact-schema open โ backup drill / restore settle โ found a different build) |
ArchetypeSchemaException |
InvalidOperationException (not a TyphonException) |
โ | ArchetypeName, Kind (ArchetypeSchemaErrorKind) |
DatabaseIntegrityException |
Exception (not a TyphonException) |
โ | Report (IntegrityReport; verify-on-open refused the file) |
UniqueConstraintViolationException |
TyphonException |
false |
โ |
ForeignKeyViolationException |
TyphonException |
ParentDying |
Child, Parent, ParentDying |
InvalidAccessException |
TyphonException |
false |
SystemName, UndeclaredType (opt-in; Typhon:Checks:DeclaredAccess) |
โ ๏ธ Guarantees & limits
- Three catch granularities by construction:
catch (TyphonException)(any engine error),catch (TyphonTimeoutException)/catch (StorageException)/catch (DurabilityException)(subsystem-wide), or a specific leaf type. IsTransientdefaults tofalse;TyphonTimeoutException(and its subclasses),ResourceExhaustedException(exceptTransactionSequenceExhaustedException) andBackupStoreLockedExceptionoverride it totrue, whileForeignKeyViolationExceptionandBackupAbortedExceptioncompute it from their state. See IsTransient Retry Hint for the full retry philosophy.- No
Contextdictionary on the base class โ every subclass exposes its diagnostic data as typed, strongly-named properties, not a string-keyed bag. ErrorCodegroups every exception into a stable, gap-numbered subsystem range โ see Error Code Classification.- Not
[Serializable]โ pre-1.0, no cross-process/cross-AppDomain exception marshaling is supported. - No nullable reference type annotations anywhere in the hierarchy (project-wide convention) โ
nullis a valid, unannotated argument where documented. - The catalog above is living โ new leaf types are added under the appropriate intermediate (or directly under
TyphonExceptionfor one-member groups) as new subsystems gain structured errors; existing types and codes are never renumbered or removed.
๐งช Tests
- TyphonExceptionTests โ the hierarchy itself:
LockTimeoutException/TransactionTimeoutExceptionare bothTyphonTimeoutException, every leaf is aTyphonException, three-granularity catch-block roundtrip (CatchGranularity_*), andErrorCode/IsTransientper leaf type.
๐ Related
- Related catalog entries: Error Code Classification, IsTransient Retry Hint, Timeout Exceptions & Deadlines, Resource Exhaustion Handling