Skip to content

Add NonFiniteEvaluationError subclass so catch sites distinguish NaN geometry from non-convergence #148

Description

@ehkropf

Follow-up from #144 / PR #146 (surfaced in the multi-agent review of #146).

#144 added std::isfinite guards to RootFinder::newton / ternarySearch that throw RootFinder::ConvergenceError on a non-finite evaluation. This is a strict improvement (fast-fail instead of spinning to maxIterations), but the new error lands in the same type as ordinary non-convergence.

Three sites catch ConvergenceError without inspecting .what():

  • src/domains/BoundaryComponent.cpp:76
  • src/domains/InvertedEllipseComponent.cpp:96
  • src/domains/SplineBoundaryComponent.cpp:146

So a NaN-producing objective now fast-fails but is swallowed into the same fallback as "didn't converge" — including the documented AnalyticBoundaryComponent::findParameterization atan2 fallback, which silently returns wrong values for non-circular boundaries.

Proposal

  • Introduce RootFinder::NonFiniteEvaluationError : public ConvergenceError and throw it from the isfinite guards (keeps existing catch (const ConvergenceError&) sites working — they still catch it).
  • Update the three catch sites to distinguish "geometry produced NaN/inf" from "failed to converge," surfacing the former instead of routing it through the (wrong) atan2 fallback.

Related

  • The atan2 silent-wrong-value behavior in findParameterization is a separate correctness bug already earmarked as out-of-scope in Guard genuine division/NaN hazards surfaced by the #40 epsilon audit #144 (needs a real fix + tests). This issue is about the error-type plumbing that would let catch sites tell the two failure modes apart; fixing the atan2 fallback itself is its own issue.

Depends on #144 (merged via PR #146).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions