Find catch (e: Exception) { throw OtherException(...) } without e as cause

Proprietary

Catching one exception and throwing a different one without passing the original as the cause argument loses the original stack trace at the throw site — debugging then starts from the wrapping exception with no breadcrumbs to the actual failure. Include e in the new exception's constructor (or use .initCause(e)).

org.openrewrite.kotlin.functional.FindCatchAndRethrowNewExceptionWithoutCause$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.functional.FindCatchAndRethrowNewExceptionWithoutCause$KtRecipe'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.