Skip to content

Make fims::Vector out-of-bounds errors actionable with vector identity, index, and size - #1667

Draft
Andrea-Havron-NOAA with Copilot wants to merge 2 commits into
mainfrom
copilot/make-fims-vector-error-info-more-informative
Draft

Make fims::Vector out-of-bounds errors actionable with vector identity, index, and size#1667
Andrea-Havron-NOAA with Copilot wants to merge 2 commits into
mainfrom
copilot/make-fims-vector-error-info-more-informative

Conversation

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

fims::Vector bounds failures currently return a generic message, which makes it hard to identify the offending vector in model wiring. This updates vector metadata and error formatting so out-of-bounds exceptions point directly to the source and failing index.

  • fims::Vector error payload improvements

    • Added variable_name_m to fims::Vector with set_variable_name() / get_variable_name().
    • Updated both operator[] overloads (const and non-const) to throw:
      • vector name (when available),
      • 1-based index (R-facing),
      • vector size.
    • Kept behavior unchanged aside from richer exception text.
  • Rcpp object wiring now names vectors at construction

    • Set set_variable_name(...) on vectors created/populated in:
      • selectivity, recruitment, maturity, population, fleet, distribution interfaces,
      • model-derived quantity vectors in rcpp_models.hpp.
    • Naming follows existing parameter-path conventions (e.g., Recruitment.<id>.log_devs, Fleet.<id>.log_Fmort), so errors align with registered parameter names.
  • Focused coverage for new diagnostics

    • Added a gtest for fims::Vector::operator[] bounds exceptions (const + non-const).
    • Asserts message contains: base error text, vector name, 1-based index, and size.
fims::Vector<double> values(2, 0.0);
values.set_variable_name("Recruitment.1.log_devs");
(void)values[2];
// throws: "fims::Vector out of bounds for Recruitment.1.log_devs: index 3 >= size 2"

Copilot AI changed the title [WIP] Improve fims::Vector out of bounds error message Make fims::Vector out-of-bounds errors actionable with vector identity, index, and size Jul 28, 2026
Copilot AI requested a review from Andrea-Havron-NOAA July 28, 2026 15:50
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.

make fims::Vector out of bounds error more informative

2 participants