← All recipes
Moderne licensed

Use rethrow instead of throw ex

Recipe IDOpenRewrite.Recipes.CSharp.CodeQuality.Redundancy.UseRethrowArtifactOpenRewrite.Recipes.CSharp.CodeQuality

Replace throw ex; with throw; inside catch clauses when ex is the caught exception variable. A bare throw preserves the original stack trace.

Single recipecsharpcode-qualityProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe OpenRewrite.Recipes.CSharp.CodeQuality.Redundancy.UseRethrow

If the recipe isn’t available locally, install it with:

mod config recipes nuget install OpenRewrite.Recipes.CSharp.CodeQuality