GC001 — No Bare Throw
This page documents the GC001 rule, which prohibits bare throw statements and throw ex rethrows in favor of returning Result<T>.
Work in Progress
This page is under construction. MonadicLeaf is in active development.
What This Rule Enforces
When this page is complete, it will explain in detail what GC001 detects: any throw statement that is not inside a catch block with a legitimate boundary reason (e.g., a top-level exception filter), and any throw ex pattern that destroys the original stack trace. These patterns are considered anti-functional because they use exceptions for control flow, making it impossible for callers to handle failures without wrapping calls in try/catch blocks.
Suggested Alternative
This section will walk through how to replace throw-based error handling with Result<T> from MonadicSharp. Instead of throwing when a value is invalid or an operation fails, methods return a Result<T> that explicitly encodes the failure path. Callers then use Match, Bind, or Map to handle both outcomes, keeping error propagation visible and composable throughout the call chain.
Auto-Fix
GC001 is one of the rules supported by ml migrate. This section will describe how the auto-fix transformation works, what patterns it can safely rewrite, and the edge cases where manual intervention is still required after running the migration.