From 9561e887713aa6e34c9aaebc2ebc6efb8dcb7c7d Mon Sep 17 00:00:00 2001 From: Katie Mummah Date: Wed, 13 Mar 2024 17:55:35 -0600 Subject: [PATCH 1/2] throw if invalid package id given --- src/context.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/context.cc b/src/context.cc index cea27a6e0b..30294c93e1 100644 --- a/src/context.cc +++ b/src/context.cc @@ -211,6 +211,9 @@ Package::Ptr Context::GetPackageByName(std::string name) { } Package::Ptr Context::GetPackageById(int id) { + if (id < 0) { + throw ValueError("Invalid package id " + std::to_string(id)); + } // iterate through the list of packages to get the one package with the correct id std::map::iterator it; for (it = packages_.begin(); it != packages_.end(); ++it) { @@ -218,6 +221,7 @@ Package::Ptr Context::GetPackageById(int id) { return it->second; } } + throw ValueError("Invalid package id " + std::to_string(id)); } void Context::InitSim(SimInfo si) { From 1b1b5aace98ffc44fa947413931352faa02845bb Mon Sep 17 00:00:00 2001 From: Katie Mummah Date: Wed, 13 Mar 2024 18:07:15 -0600 Subject: [PATCH 2/2] CHANGELOG --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0c45dcc2af..352a49e92c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -27,7 +27,7 @@ Since last release * Adds support for Cython3 (#1636) * Adds TotalInvTracker, which allows an inventory cap to be set for multiple resource buffers, and is now required for material buy policy (#1646) * AddMutalReqs and AddReciepe functions and exclusive bids in python API of DRE (#1584) -* Created Package class and optional declaration of packages in input files (#1673), package id is a member of resources (materials/products) (#1675) +* Created Package class and optional declaration of packages in input files (#1673, #1699), package id is a member of resources (materials/products) (#1675) * CI support for Rocky Linux (#1691) **Changed:**