DSH / Atlas
Otherdsh-error-handling

dsh-error-handling

Apply error-handling principles when designing or reviewing failures, recovery, retries, background tasks, and user-visible error reports.

Workflow

    Full instructions

    DeepSeek Harness Error Handling

    Define failures, their owners, and what remains safe after failure.

    Typed, structured failures

    Expected failures need declared types, stable discriminants, and handling-relevant details. Reuse package error conventions, preserve causes, and separate machine identity from display text. Never route handling by parsing messages. Unexpected defects such as assertNever may remain plain Error; containment must never turn them into success.

    Catch, recover, or stop

    For each failure, define handling and reporting owners, containment, and guarantees in the owning API documentation: valid invariants, absent/partial/committed/unknown effects, and cleanup responsibility. Background work retains these obligations.

    Catching limits exception propagation, not mutations. Only the affected state's owner can establish safe continuation. Otherwise stop dependent work, discard invalid state or instances, or escalate. Logging alone is not recovery. Retries require safe repetition, cancellation, and an explicit owner; finite operations need budgets, while continuing supervision needs lifecycle ownership and observable degradation.

    Localized, actionable, visible reports

    Every final report needs a readable summary, affected operation, and safe next action. Localize through the receiving application's locale mechanism where one exists; other diagnostics use their existing output language. Keep sensitive internal details out of user-facing text.

    Untrusted state or unknown outcomes must be visible through UI or default-enabled, accessible logs: report the impact, uncertainty, system disposition, and safe next step. Persistent invalid state needs persistent visibility. Never claim success, rollback, or safe retry without guarantees. Reporting failures need an independent fallback.

    Verify resulting state and visible outcomes, not merely that an exception was caught.

    Foundations

    Meyer's Object-Oriented Software Construction (1997): contracts and invariants; Sutter's Exceptional C++ (1999): exception safety guarantees; Armstrong's thesis (2003): isolation and supervision.