Update Error helper functions#864
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #864 +/- ##
==========================================
- Coverage 73.18% 73.03% -0.16%
==========================================
Files 127 132 +5
Lines 10219 10228 +9
==========================================
- Hits 7479 7470 -9
- Misses 2740 2758 +18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors MUSICA’s shared utility/error layer by splitting the old utility header/source into separate utils components, introducing typed error-code/exception helpers, and updating MICM/TUV-x/bindings/tests to the new layout. It also adjusts CI by moving the FetchContent workflow out of the active workflow set.
Changes:
- Split string/error/util functionality into new
include/musica/utils/*andsrc/utils/*files. - Switched many MICM/TUV-x error paths to the new error-code/exception plumbing and updated tests/bindings to match new categories/includes.
- Removed the active FetchContent CI job from
docker.ymland added a disabled standalone workflow file.
Reviewed changes
Copilot reviewed 53 out of 53 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/util.cpp | Keeps config/mapping utilities after split |
| src/utils/string.cpp | New string helper implementation |
| src/utils/error_handler.cpp | New error helper implementation |
| src/utils/error_code.cpp | New error-category definitions |
| src/tuvx/tuvx.cpp | Broadens TUV-x exception catches |
| src/tuvx/tuvx_c_interface.cpp | Broadens C interface exception catch |
| src/tuvx/radiator.cpp | Broadens radiator exception catches |
| src/tuvx/radiator_map.cpp | Broadens radiator-map exception catches |
| src/tuvx/profile.cpp | Broadens profile exception catches |
| src/tuvx/profile_map.cpp | Broadens profile-map exception catches |
| src/tuvx/grid.cpp | Broadens grid exception catch |
| src/tuvx/grid_map.cpp | Broadens grid-map exception catches |
| src/test/unit/util.cpp | Updates util/error assertions |
| src/test/unit/micm/micm_c_api.cpp | Updates MICM error assertions |
| src/micm/v1_parse.cpp | Switches parser throws to musica::Exception |
| src/micm/v0_parse.cpp | Switches parser throws to musica::Exception |
| src/micm/state.cpp | Updates util include path |
| src/micm/state_c_interface.cpp | Removes local error wrapper, updates codes |
| src/micm/parse.cpp | Uses new parse error codes |
| src/micm/micm.cpp | Uses new MICM error codes |
| src/micm/micm_c_interface.cpp | Uses shared HandleErrors helper |
| src/micm/cpu_solver.cpp | Uses new exception/error-code types |
| src/micm/convert_v0_to_v1.cpp | Uses new parse exception type |
| src/cuda/cuda_solver.cpp | Updates util include path |
| src/CMakeLists.txt | Repoints common utility sources |
| python/test/unit/test_error_handling.py | Updates referenced error header path |
| python/bindings/tuvx/tuvx.cpp | Updates util include path |
| python/bindings/error.hpp | Updates util include path |
| python/bindings/error.cpp | Updates error header path |
| javascript/bindings/musica_wasm.cpp | Updates util include path |
| include/musica/utils/util.hpp | New split utility public header |
| include/musica/utils/string.hpp | New public string header |
| include/musica/utils/error.hpp | New public error macro header |
| include/musica/utils/error_handler.hpp | New public error helper header |
| include/musica/utils/error_code.hpp | New public error-code header |
| include/musica/tuvx/tuvx.hpp | Updates util include path |
| include/musica/tuvx/radiator.hpp | Updates util include path |
| include/musica/tuvx/radiator_map.hpp | Updates util include path |
| include/musica/tuvx/profile.hpp | Updates util include path |
| include/musica/tuvx/profile_map.hpp | Updates util include path |
| include/musica/tuvx/grid.hpp | Updates util include path |
| include/musica/tuvx/grid_map.hpp | Updates util include path |
| include/musica/micm/state_c_interface.hpp | Updates util include path |
| include/musica/micm/solver_interface.hpp | Updates exception docs/includes |
| include/musica/micm/parse.hpp | Removes legacy parse error machinery |
| include/musica/micm/micm.hpp | Removes legacy MICM error machinery |
| include/musica/micm/micm_c_interface.hpp | Updates util include path |
| include/musica/error.hpp | Deletes legacy public error header |
| fortran/util.F90 | Updates included error header path |
| fortran/test/unit/util.F90 | Updates included error header path |
| fortran/test/integration/test_micm_api.F90 | Updates parse error macro names |
| .github/workflows/fetch-content.yml.disabled | Disabled standalone FetchContent workflow |
| .github/workflows/docker.yml | Removes active FetchContent job |
Comments suppressed due to low confidence (2)
include/musica/utils/util.hpp:7
- The package no longer installs the old
<musica/util.hpp>entry point or theIsError(...)helper that downstream code used from it. That turns this refactor into a source-breaking public API change for external consumers unless you keep a compatibility shim.
src/utils/util.cpp:95 - The new
configuration.data_ == nullptrearly-return path is not exercised by the existing util tests, even though this file already has goodCreateIndexMappingscoverage. Please add a unit test for callingCreateIndexMappingswith a default/clearedConfigurationso this new error contract does not regress silently.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
K20shores
left a comment
There was a problem hiding this comment.
Beautiful PR. I feel like this is at least slightly simpler than what we were doing before, and maybe even less error prone. Couple of questions though
| /// @brief Singleton category declarations | ||
| const std::error_category& musica_category(); | ||
| const std::error_category& micm_category(); | ||
| const std::error_category& parse_category(); |
There was a problem hiding this comment.
Why do we need singletons for these? We shouldn't do this if we don't need to. musica could potentially be called from multiple threads in a downstream model and the static initialization order could cause some issues. If we really need these, we probably need to throw a mutex in the constructors for these
| /// These are provided solely to support the short-form Exception constructor | ||
| template<typename T> const char* error_category_for(); | ||
| template<> inline const char* error_category_for<ErrorCode>() { return MUSICA_ERROR_CATEGORY; } | ||
| template<> inline const char* error_category_for<MicmErrorCode>() { return MUSICA_MICM_ERROR_CATEGORY; } | ||
| template<> inline const char* error_category_for<ParseErrorCode>() { return MUSICA_PARSE_ERROR_CATEGORY; } |
There was a problem hiding this comment.
Seems like we only use error_category_for<ErrorCodeEnum>? Do we really need these?
In progress
This PR:
error,string, andutilvoid ToError(const char* category, int code, int severity, Error* error);because the 3 argument overload is only defined but never called.DeleteIndexMappingthat never needs individual clean up (containssize_tanddouble)DeleteMappingsandDeleteIndexMappings