-
Notifications
You must be signed in to change notification settings - Fork 99
refactor: Remove getDataContext duplication #3895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… link between GEOS_THROW_CTX_IF and LVARRAY_THROW_IF_TEST( EXP, MSG, TYPE )
… in try/catch statements Problem: Retrieves everything that was thrown, so not just the message.
…/catch in main)": remove useless try/catch
…y spaces. The previous condition checked whether an argument was present and whether the option was immediately followed by a value like -test"value", which excluded valid cases like -test "value" et -test "value".
MelReyCG
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
dkachuma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Are you able to add in the description an example of the change in the output message - just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed these remnants of debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot
OmarDuran
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent refactor, thanks @arng40
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors logging/exception call sites to avoid duplicating getDataContext() / wrapper context in error strings and to ensure missing DataContext objects are passed via the GEOS_* macro parameters.
Changes:
- Removed inline context prefixes from many error/warning strings (e.g.,
getDataContext() << ": ..."), relying on macro-provided contexts instead. - Added missing
DataContextarguments toGEOS_ERROR*,GEOS_WARNING*,GEOS_THROW*,GEOS_ASSERT*call sites for improved diagnostics consistency. - Updated a mesh integration test to validate new exception text expectations.
Reviewed changes
Copilot reviewed 152 out of 152 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreComponents/physicsSolvers/wavePropagation/shared/WaveSolverBase.cpp | Refactors throws to pass DataContext separately. |
| src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/secondOrderEqn/isotropic/ElasticWaveEquationSEM.cpp | Refactors errors/throws to use context parameters. |
| src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/firstOrderEqn/isotropic/ElasticFirstOrderWaveEquationSEM.cpp | Refactors errors/throws to use context parameters. |
| src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationSEM.cpp | Refactors throws to pass DataContext separately. |
| src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/anisotropic/AcousticVTIWaveEquationSEM.cpp | Refactors error to pass DataContext separately. |
| src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/firstOrderEqn/isotropic/AcousticFirstOrderWaveEquationSEM.cpp | Refactors errors/throws to use context parameters. |
| src/coreComponents/physicsSolvers/wavePropagation/dg/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationDG.cpp | Adds missing DataContext to throws/errors. |
| src/coreComponents/physicsSolvers/solidMechanics/contact/SolidMechanicsLagrangeContact.cpp | Refactors errors to provide DataContext as macro args. |
| src/coreComponents/physicsSolvers/solidMechanics/contact/SolidMechanicsAugmentedLagrangianContact.cpp | Refactors error to include DataContext. |
| src/coreComponents/physicsSolvers/solidMechanics/contact/ContactSolverBase.cpp | Refactors throw/error message formatting + adds DataContext. |
| src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsStateReset.cpp | Refactors throw message and passes DataContext. |
| src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsMPM.cpp | Refactors errors to pass DataContext. |
| src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp | Refactors errors/warnings to pass DataContext separately. |
| src/coreComponents/physicsSolvers/multiphysics/SinglePhaseReservoirAndWells.cpp | Refactors errors/throws to pass DataContext. |
| src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsEmbeddedFractures.cpp | Refactors error to pass DataContext. |
| src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.cpp | Refactors errors to pass DataContext. |
| src/coreComponents/physicsSolvers/multiphysics/PoromechanicsSolver.hpp | Refactors throws to pass solver-specific DataContext. |
| src/coreComponents/physicsSolvers/multiphysics/PoromechanicsInitialization.cpp | Refactors wrapper-context usage in throws. |
| src/coreComponents/physicsSolvers/multiphysics/PoromechanicsConformingFractures.hpp | Refactors error to pass DataContext. |
| src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.cpp | Refactors errors to pass DataContext. |
| src/coreComponents/physicsSolvers/multiphysics/CoupledSolver.hpp | Refactors solver-not-found path to throw with wrapper DataContext. |
| src/coreComponents/physicsSolvers/multiphysics/CoupledReservoirAndWellsBase.cpp | Refactors throw message to avoid embedded context text. |
| src/coreComponents/physicsSolvers/multiphysics/CompositionalMultiphaseReservoirAndWells.cpp | Refactors errors/throws to pass multiple contexts. |
| src/coreComponents/physicsSolvers/inducedSeismicity/SpringSlider.cpp | Refactors error to pass multiple contexts. |
| src/coreComponents/physicsSolvers/fluidFlow/wells/kernels/SinglePhaseWellKernels.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/physicsSolvers/fluidFlow/wells/kernels/CompositionalMultiphaseWellKernels.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp | Refactors throw to pass DataContext. |
| src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWell.cpp | Refactors errors/throws to pass DataContext. |
| src/coreComponents/physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.cpp | Refactors errors/warnings to pass DataContext. |
| src/coreComponents/physicsSolvers/fluidFlow/StencilDataCollection.cpp | Refactors errors/throws to pass DataContext. |
| src/coreComponents/physicsSolvers/fluidFlow/SourceFluxStatistics.cpp | Refactors warning/error messages and context parameters. |
| src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseStatistics.cpp | Refactors warning to pass DataContext. |
| src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVM.cpp | Refactors throw/warning paths and adds logger include. |
| src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBase.cpp | Refactors throws/logs to avoid embedded context strings. |
| src/coreComponents/physicsSolvers/fluidFlow/ReactiveCompositionalMultiphaseOBL.cpp | Refactors throws/warnings to pass DataContext. |
| src/coreComponents/physicsSolvers/fluidFlow/ImmiscibleMultiphaseFlow.cpp | Refactors warnings/errors to pass DataContext. |
| src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBase.cpp | Refactors errors to pass DataContext. |
| src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseStatistics.cpp | Refactors throw to include DataContext. |
| src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp | Refactors errors/throws/warnings and adds logger include. |
| src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp | Refactors errors to pass DataContext. |
| src/coreComponents/physicsSolvers/PhysicsSolverBase.hpp | Refactors error to pass DataContext separately. |
| src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp | Refactors errors/warnings to pass DataContext. |
| src/coreComponents/physicsSolvers/NonlinearSolverParameters.cpp | Refactors input validation errors to pass wrapper DataContext. |
| src/coreComponents/physicsSolvers/LinearSolverParameters.cpp | Refactors input validation errors to pass wrapper DataContext. |
| src/coreComponents/physicsSolvers/FieldStatisticsBase.hpp | Refactors throw message to avoid embedded context string. |
| src/coreComponents/mesh/simpleGeometricObjects/ThickPlane.cpp | Refactors errors to pass DataContext. |
| src/coreComponents/mesh/simpleGeometricObjects/Box.cpp | Refactors errors to pass DataContext. |
| src/coreComponents/mesh/generators/WellGeneratorBase.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/mesh/generators/VTKWellGenerator.cpp | Refactors error to pass DataContext. |
| src/coreComponents/mesh/generators/VTKMeshGenerator.cpp | Refactors throw/error to pass DataContext. |
| src/coreComponents/mesh/generators/ParticleBlock.cpp | Refactors error to pass DataContext. |
| src/coreComponents/mesh/generators/InternalMeshGenerator.cpp | Refactors errors to pass DataContext. |
| src/coreComponents/mesh/generators/CellBlock.cpp | Refactors error to pass DataContext. |
| src/coreComponents/mesh/WellElementSubRegion.cpp | Refactors throw messages to avoid embedded context prefix. |
| src/coreComponents/mesh/WellElementRegion.cpp | Adds DataContext to throw and updates comments. |
| src/coreComponents/mesh/SurfaceElementRegion.hpp | Refactors error message + passes DataContext. |
| src/coreComponents/mesh/PerforationData.cpp | Adds missing DataContext to throws. |
| src/coreComponents/mesh/Perforation.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/mesh/ObjectManagerBase.cpp | Refactors error to pass DataContext. |
| src/coreComponents/mesh/MeshObjectPath.cpp | Refactors throws to use names + pass DataContext. |
| src/coreComponents/mesh/MeshLevel.cpp | Refactors error to pass multiple DataContexts. |
| src/coreComponents/mesh/FaceManager.cpp | Refactors errors to pass DataContext. |
| src/coreComponents/mesh/FaceElementSubRegion.cpp | Refactors warnings/errors to pass DataContext. |
| src/coreComponents/mesh/ElementRegionManager.hpp | Refactors errors to avoid embedded context text. |
| src/coreComponents/mesh/ElementRegionManager.cpp | Refactors errors to pass multiple DataContexts. |
| src/coreComponents/mesh/CellElementSubRegion.cpp | Refactors errors; introduces new format-string/arg mismatch risk. |
| src/coreComponents/mesh/CellElementRegionSelector.cpp | Refactors throws to avoid embedded wrapper context in message. |
| src/coreComponents/mesh/CellElementRegion.cpp | Refactors throws to avoid embedded context text. |
| src/coreComponents/integrationTests/meshTests/testElementRegions.cpp | Updates test expectations for new exception strings (currently broken). |
| src/coreComponents/functions/TableFunction.cpp | Refactors error/throw formatting and context usage. |
| src/coreComponents/finiteVolume/HybridMimeticDiscretization.cpp | Refactors error to pass DataContext. |
| src/coreComponents/fileIO/Outputs/VTKOutput.cpp | Refactors input validation errors/logs to pass DataContext. |
| src/coreComponents/fileIO/Outputs/SiloOutput.cpp | Refactors logs/throws to avoid embedded context in message. |
| src/coreComponents/fileIO/Outputs/MemoryStatsOutput.cpp | Refactors error to pass DataContext. |
| src/coreComponents/fieldSpecification/TractionBoundaryCondition.cpp | Refactors logs/errors and enum string formatting. |
| src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.cpp | Refactors throws to avoid embedded context in message. |
| src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp | Adds missing DataContext to throws. |
| src/coreComponents/fieldSpecification/EquilibriumInitialCondition.cpp | Refactors throws/warnings to pass DataContext. |
| src/coreComponents/fieldSpecification/AquiferBoundaryCondition.cpp | Refactors throws to pass DataContext (including table context). |
| src/coreComponents/events/PeriodicEvent.cpp | Refactors throw messages to avoid embedded context. |
| src/coreComponents/dataRepository/Group.hpp | Refactors domain/type errors to avoid embedded context prefixes. |
| src/coreComponents/dataRepository/Group.cpp | Refactors error/throw messages to avoid embedded context. |
| src/coreComponents/constitutiveDrivers/solid/TriaxialDriver.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutiveDrivers/fluid/multiFluid/PVTDriver.cpp | Refactors warnings to avoid embedded wrapper context in message. |
| src/coreComponents/constitutive/thermalConductivity/SinglePhaseThermalConductivity.cpp | Refactors throw message + passes DataContext. |
| src/coreComponents/constitutive/thermalConductivity/MultiPhaseVolumeWeightedThermalConductivity.cpp | Refactors throws to avoid embedded full-name text. |
| src/coreComponents/constitutive/thermalConductivity/MultiPhaseThermalConductivityBase.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/thermalConductivity/MultiPhaseConstantThermalConductivity.cpp | Refactors throw message + passes DataContext. |
| src/coreComponents/constitutive/solid/PerfectlyPlastic.cpp | Adds missing DataContext to throw. |
| src/coreComponents/constitutive/solid/ModifiedCamClay.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/solid/ElasticOrthotropic.cpp | Refactors errors to pass DataContext. |
| src/coreComponents/constitutive/solid/ElasticIsotropicPressureDependent.cpp | Refactors errors/throws to pass DataContext. |
| src/coreComponents/constitutive/solid/ElasticIsotropic.cpp | Refactors errors to pass DataContext. |
| src/coreComponents/constitutive/solid/DruckerPragerExtended.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/solid/DruckerPrager.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/solid/DelftEgg.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/solid/Damage.cpp | Refactors errors to pass DataContext. |
| src/coreComponents/constitutive/solid/CoupledSolid.hpp | Refactors errors to pass DataContext. |
| src/coreComponents/constitutive/solid/CeramicDamage.cpp | Adds missing DataContext to throws. |
| src/coreComponents/constitutive/relativePermeability/VanGenuchtenStone2RelativePermeability.cpp | Refactors validation throws to pass DataContext. |
| src/coreComponents/constitutive/relativePermeability/VanGenuchtenBakerRelativePermeability.cpp | Refactors validation throws to pass DataContext. |
| src/coreComponents/constitutive/relativePermeability/TableRelativePermeabilityHelpers.cpp | Refactors validation messages/contexts. |
| src/coreComponents/constitutive/relativePermeability/TableRelativePermeability.cpp | Refactors throws to avoid embedded full-name text. |
| src/coreComponents/constitutive/relativePermeability/RelativePermeabilityBase.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/relativePermeability/BrooksCoreyStone2RelativePermeability.cpp | Refactors validation throws to pass DataContext. |
| src/coreComponents/constitutive/relativePermeability/BrooksCoreyRelativePermeability.cpp | Refactors validation throws to pass DataContext. |
| src/coreComponents/constitutive/relativePermeability/BrooksCoreyBakerRelativePermeability.cpp | Refactors validation throws to pass DataContext. |
| src/coreComponents/constitutive/permeability/PressurePermeability.cpp | Refactors error to pass DataContext. |
| src/coreComponents/constitutive/fluid/twophaseimmisciblefluid/TwoPhaseImmiscibleFluid.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/singlefluid/ThermalCompressibleSinglePhaseFluid.cpp | Refactors validation throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/singlefluid/SlurryFluidBase.cpp | Refactors errors to pass DataContext. |
| src/coreComponents/constitutive/fluid/singlefluid/ProppantSlurryFluid.cpp | Refactors validation errors to pass DataContext. |
| src/coreComponents/constitutive/fluid/singlefluid/ParticleFluid.cpp | Refactors validation errors to pass DataContext. |
| src/coreComponents/constitutive/fluid/singlefluid/CompressibleSinglePhaseFluid.cpp | Refactors validation throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/reactive/ReactiveBrineFluid.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/constant/InvariantImmiscibleFluid.cpp | Refactors throws but introduces invalid GEOS_FMT format strings. |
| src/coreComponents/constitutive/fluid/multifluid/compositional/parameters/PressureTemperatureCoordinates.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/compositional/parameters/KValueFlashParameters.cpp | Adds missing DataContext to throws. |
| src/coreComponents/constitutive/fluid/multifluid/compositional/parameters/ImmiscibleWaterParameters.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/compositional/parameters/FlashParameters.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/compositional/parameters/EquationOfState.hpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/compositional/parameters/CriticalVolume.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/compositional/parameters/BrineSalinity.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/compositional/models/ConstantViscosity.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluidPVTPackage.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluid.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluidBase.cpp | Refactors throws to pass wrapper DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluid.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/fluid/multifluid/MultiFluidBase.cpp | Refactors validation throws to pass DataContext. |
| src/coreComponents/constitutive/dispersion/LinearIsotropicDispersion.cpp | Refactors throw message + passes DataContext. |
| src/coreComponents/constitutive/diffusion/DiffusionBase.cpp | Refactors throws to pass wrapper DataContexts. |
| src/coreComponents/constitutive/diffusion/ConstantDiffusion.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/contact/HydraulicApertureTable.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/contact/CoulombFriction.cpp | Refactors throw message formatting. |
| src/coreComponents/constitutive/contact/BartonBandis.cpp | Adds missing DataContext to throw. |
| src/coreComponents/constitutive/capillaryPressure/VanGenuchtenCapillaryPressure.cpp | Refactors validation throws to pass DataContext. |
| src/coreComponents/constitutive/capillaryPressure/TableCapillaryPressureHelpers.cpp | Refactors validation messages/contexts and removes unused name parameter. |
| src/coreComponents/constitutive/capillaryPressure/TableCapillaryPressure.cpp | Refactors throws to avoid embedded full-name text. |
| src/coreComponents/constitutive/capillaryPressure/JFunctionCapillaryPressure.cpp | Refactors throws to avoid embedded full-name text. |
| src/coreComponents/constitutive/capillaryPressure/CapillaryPressureBase.cpp | Refactors throws to pass DataContext. |
| src/coreComponents/constitutive/capillaryPressure/BrooksCoreyCapillaryPressure.cpp | Refactors validation throws to pass DataContext. |
| src/coreComponents/constitutive/ConstitutivePassThruHandler.hpp | Refactors error to pass DataContext. |
| src/coreComponents/constitutive/ConstitutivePassThru.hpp | Refactors errors to pass DataContext. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| GEOS_ERROR( GEOS_FMT( "Volume calculation not supported for element type {} in subregion {}", | ||
| m_elementType, getDataContext() ) ); | ||
| m_elementType ), getDataContext() ); | ||
| } | ||
| } | ||
|
|
||
| GEOS_ERROR_IF( m_elementVolume[k] <= 0.0, | ||
| GEOS_FMT( "Negative volume for element {} type {} in subregion {}", | ||
| k, m_elementType, getDataContext() ) ); | ||
| k, m_elementType ), getDataContext() ); |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GEOS_FMT format strings contain two/three {} placeholders but only pass one/two arguments (the subregion identifier was dropped). With fmt/std::format this will raise a format_error when the error path is hit, masking the intended diagnostic. Pass the missing subregion value (e.g., name/context string) or remove the extra {} placeholders so placeholders and arguments match.
| integer numPhase = numFluidPhases(); | ||
| // check densities and viscosities size | ||
| GEOS_THROW_IF_NE_MSG( m_densities.size(), numPhase, | ||
| GEOS_FMT( "%s: 'Densities' must have %d values", getFullName(), numPhase ), InputError ); | ||
| GEOS_FMT( "'Densities' must have %d values", numPhase ), InputError, getDataContext() ); | ||
| GEOS_THROW_IF_NE_MSG( m_viscosities.size(), numPhase, | ||
| GEOS_FMT( "%s: 'Viscosities' must have %d values", getFullName(), numPhase ), InputError ); | ||
| GEOS_FMT( "'Viscosities' must have %d values", numPhase ), InputError, getDataContext() ); | ||
|
|
||
| integer numComponents = numFluidComponents(); | ||
| // check tacit assumption of one component per phase | ||
| GEOS_THROW_IF_NE_MSG( numComponents, numPhase, | ||
| GEOS_FMT( "%d number of components must be equato to %d number of phases", getFullName(), numPhase ), InputError ); | ||
| GEOS_FMT( "number of components must be equato to %d number of phases", numPhase ), InputError, getDataContext() ); | ||
| } |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These GEOS_FMT strings use printf-style %d but GEOS_FMT is backed by fmt/std::format (uses {} placeholders). As written, the formatting will throw (extra argument / invalid format), so the intended InputError message may never be produced. Replace %d with {} (and consider also fixing the typo "equato" -> "equal").
| std::vector< string > strEq{ | ||
| "***** Rank 0: No cellBlock name is satisfying the qualifier 'helloWorld'." | ||
| "Available cellBlock list: { 1, 2, 5, 6 }" | ||
| "Available region attribute list: { 1_hexahedra, 1_pyramids, 1_tetrahedra, 2_hexahedra, 2_pyramids, 2_tetrahedra, 5_hexahedra, 5_pyramids, 5_tetrahedra, 6_hexahedra, 6_pyramids, 6_tetrahedra }" | ||
| }; | ||
| for( auto const & str : strEq ) | ||
| { | ||
| bool isExceptionContainingStr = expStr.find( str ) != string::npos; | ||
| EXPECT_TRUE( isExceptionContainingStr ) << GEOS_FMT( "Test case '{}' exception did not mention the string '{}'. Exception string:\n{}", | ||
| testCase.name, str, e.what() ); | ||
| EXPECT_TRUE( string( e.what()).find( str ) ); | ||
| } |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test will fail: (1) the first two string literals in strEq are missing a comma, so they concatenate into a single string; (2) EXPECT_TRUE(string(e.what()).find(str)) is incorrect because find returns 0 when the substring is at the beginning (evaluates to false) and it never compares against npos. Store std::string expStr = e.what(); and use EXPECT_NE(expStr.find(str), std::string::npos) with correctly separated expected substrings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may not have all the information needed to do the check in well generator
Remove all getDataContext() / getWrapperDataContext() / getName() written directly in the error message strings (getDataContext() << “: blabla”).
Add missing DataContexts when they are not present in the error DataContext parameters (GEOS_ERROR*, GEOS_ASSERT*, GEOS_WARNING*, GEOS_THROW*)
Example:
Before:
After