Dev.to
5/9/2026

Why I stopped using exceptions for control flow in my .NET 8 APIs
Short summary
The author replaced exception-based error handling with the ErrorOr library, a discriminated union pattern that treats errors as return values instead of exceptions. This eliminates the performance overhead of throwing/catching, makes error contracts explicit at compile-time rather than runtime, and forces callers to handle both success and failure paths. The pattern includes structured error definitions with types, codes, and descriptions, with validation short-circuiting before database operations.
- •ErrorOr library brings Result<T, E> pattern from Rust/Go to .NET
- •Errors are return values, not exceptions; forces explicit handling at call site
- •Improves performance, compile-time safety, clearer API contracts
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



