09.1 Errors and Result
Represent recoverable failures with enums and propagate them with try/? — not exceptions.
Errors and Result
Beskid does not resurrect C# exceptions for breakfast. Recoverable failures are values you pattern-match, propagate with ?, and translate at boundaries.
Result and friends
Section titled “Result and friends”Normative rules: Error handling.
- Model errors as
enumvariants (Ok/Error domain-specific shapes). Option<T>is the optional type—there is nooptionalkeyword.- Postfix
?on aResult-like expression: success unwraps;Errreturns or translates from the current function.
flowchart LR expr[Expression with Result type] q[Postfix ?] ok[Continue with success value] err[Return Err from enclosing callable] expr --> q q -->|Ok| ok q -->|Err| err
FFI and envelopes
Section titled “FFI and envelopes”At foreign boundaries, errors become ABI envelopes—no silent throw across the wall. See Interop contracts and Error and unwind semantics.
What you should do in application code
Section titled “What you should do in application code”| Practice | Why |
|---|---|
| Named error enums per domain | Callers can handle variants without string archaeology |
? for happy-path plumbing | Less nesting than manual match everywhere |
| Translate at module boundaries | Keep internal Err types out of public APIs |
Diagnostics
Section titled “Diagnostics”Type and flow mistakes surface as compiler diagnostics in the E16xx band (contract-related) and analysis rules tied to semantic pipeline.