Skip to content

Errors#948

Merged
K20shores merged 6 commits intomainfrom
errors
Mar 18, 2026
Merged

Errors#948
K20shores merged 6 commits intomainfrom
errors

Conversation

@K20shores
Copy link
Collaborator

@K20shores K20shores commented Mar 12, 2026

Closes #861

  • Replaces all of the system error boilerplate with a class that contains the code, category, severity, and error message
  • I believe this maintains the compatibility we need for our fortran interface while simplifying error handling
  • This also standardizes the error message between the cpu and gpu interfaces
  • This works is useful to fulfil requirements in mpas

Claude did a lot of the work. I am happy to close this PR if we don't find it useful

@codecov-commenter
Copy link

codecov-commenter commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 60.55046% with 43 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.94%. Comparing base (ad00ab7) to head (ddad746).

Files with missing lines Patch % Lines
include/micm/solver/state.inl 33.33% 16 Missing ⚠️
include/micm/util/sparse_matrix.hpp 62.50% 6 Missing ⚠️
include/micm/process/process_set.hpp 0.00% 4 Missing ⚠️
include/micm/solver/solver_builder.inl 33.33% 2 Missing ⚠️
...rix_standard_ordering_compressed_sparse_column.hpp 60.00% 2 Missing ⚠️
...matrix_standard_ordering_compressed_sparse_row.hpp 60.00% 2 Missing ⚠️
...atrix_vector_ordering_compressed_sparse_column.hpp 60.00% 2 Missing ⚠️
...e_matrix_vector_ordering_compressed_sparse_row.hpp 60.00% 2 Missing ⚠️
include/micm/constraint/linear_constraint.hpp 0.00% 1 Missing ⚠️
include/micm/process/chemical_reaction.hpp 0.00% 1 Missing ⚠️
... and 5 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #948      +/-   ##
==========================================
+ Coverage   94.61%   95.94%   +1.32%     
==========================================
  Files          69       65       -4     
  Lines        3973     3870     -103     
==========================================
- Hits         3759     3713      -46     
+ Misses        214      157      -57     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors MICM’s error handling away from per-module std::system_error boilerplate into a unified micm::MicmException carrying severity, category, and integer error codes, with corresponding test updates to validate the new exception type/codes across CPU and CUDA paths.

Changes:

  • Introduces micm::MicmException / MicmSeverity and updates code to throw it instead of std::system_error.
  • Removes several legacy *_error.hpp headers that implemented std::error_category/make_error_code for modules.
  • Updates unit tests to expect MicmException and validate MICM error codes directly.

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
test/unit/util/test_sparse_matrix_standard_ordering_row.cpp Updates sparse-matrix builder tests to expect MicmException and matrix error codes.
test/unit/util/test_sparse_matrix_standard_ordering_column.cpp Same as above for column ordering.
test/unit/util/test_sparse_matrix_policy.hpp Updates matrix policy tests to check MicmException::code_ against matrix error codes.
test/unit/system/test_species.cpp Updates species property tests to catch MicmException and verify species error codes.
test/unit/solver/test_solver_builder.cpp Updates solver builder test to expect MicmException.
test/unit/process/rate_constant/test_surface_rate_constant.cpp Updates surface rate constant tests to catch MicmException and validate species error codes.
test/unit/constraint/test_equilibrium_constraint.cpp Updates constraint tests to expect MicmException.
test/unit/constraint/test_constraint_set.cpp Updates constraint-set tests to expect MicmException.
src/util/cuda_util.cu Replaces internal-error helper with MicmException throws for CUDA/CUBLAS errors.
src/util/cuda_matrix.cu Removes now-unused internal error include (cleanup after error refactor).
src/solver/rosenbrock.cu Replaces INTERNAL_ERROR usage with MicmException for internal CUDA solver mismatches.
include/micm/util/vector_matrix.hpp Replaces matrix std::system_error throws with MicmException.
include/micm/util/sparse_matrix_vector_ordering_compressed_sparse_row.hpp Switches sparse row ordering errors to MicmException.
include/micm/util/sparse_matrix_vector_ordering_compressed_sparse_column.hpp Switches sparse column ordering errors to MicmException.
include/micm/util/sparse_matrix_standard_ordering_compressed_sparse_row.hpp Switches standard CSR ordering errors to MicmException.
include/micm/util/sparse_matrix_standard_ordering_compressed_sparse_column.hpp Switches standard CSC ordering errors to MicmException and includes new exception header.
include/micm/util/sparse_matrix.hpp Replaces sparse-matrix std::system_error throws with MicmException.
include/micm/util/micm_exception.hpp Adds the new unified exception type and severity enum.
include/micm/util/matrix_error.hpp Removes legacy matrix std::error_category error plumbing.
include/micm/util/matrix.hpp Replaces dense-matrix std::system_error throws with MicmException.
include/micm/util/internal_error.hpp Removes legacy internal error helper/macro.
include/micm/system/species.hpp Replaces species std::system_error throws with MicmException and removes legacy category boilerplate.
include/micm/solver/state.inl Replaces state std::system_error throws with MicmException and removes legacy category boilerplate.
include/micm/solver/state.hpp Ensures state includes required headers for new exception usage.
include/micm/solver/solver_error.hpp Removes legacy solver std::error_category error plumbing.
include/micm/solver/solver_builder.inl Switches solver builder errors/warnings to MicmException with severity.
include/micm/solver/solver_builder.hpp Removes legacy solver error header include.
include/micm/process/rate_constant/user_defined_rate_constant.hpp Switches missing-argument error to MicmException.
include/micm/process/rate_constant/surface_rate_constant.hpp Switches missing-property/missing-argument errors to MicmException.
include/micm/process/rate_constant/rate_constant.hpp Removes legacy rate-constant std::error_category boilerplate and includes new exception header.
include/micm/process/process_set.hpp Switches process validation errors to MicmException.
include/micm/process/process_error.hpp Removes legacy process std::error_category error plumbing.
include/micm/process/phase_transfer_process_builder.hpp Switches null coefficient error to MicmException.
include/micm/process/phase_transfer_process.hpp Switches validation/copy errors to MicmException.
include/micm/process/chemical_reaction_builder.hpp Switches missing rate constant error to MicmException.
include/micm/process/chemical_reaction.hpp Switches validation/copy errors to MicmException.
include/micm/constraint/equilibrium_constraint.hpp Switches constraint validation errors to MicmException.
include/micm/constraint/constraint_set.hpp Switches unknown-species constraint error to MicmException.
include/micm/constraint/constraint_error.hpp Removes legacy constraint std::error_category error plumbing.
include/micm/Util.hpp Updates umbrella include to expose micm_exception.hpp and removes legacy error headers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

K20shores and others added 6 commits March 18, 2026 15:15
- Change category_ member from string_view to const char* to avoid
  dangling reference risk when passing temporaries
- Add direct include of micm_exception.hpp to sparse_matrix.hpp and
  sparse_matrix_standard_ordering_compressed_sparse_row.hpp
- Fix matrix.hpp bug where constructed msg was dropped (passed "" instead)
- Fill in all empty exception message strings across matrix, sparse
  matrix, constraint, rate constant, and state throw sites

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@K20shores K20shores merged commit 032b30e into main Mar 18, 2026
26 checks passed
@K20shores K20shores deleted the errors branch March 18, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Classify all error messages as WARN, ERR, or CRIT in error.hpp

4 participants