Fix potential map::at error
There are some potential errors, when using the map::at method,
the process may hang due to out of bounds. so the exception should
be caught.
Also, use the map::contains method of C++20 instead of map::find.
Tested: built pldm successfully and worked.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ia5d7dea906e5c598072c08b27387195ef1201839
diff --git a/libpldmresponder/platform_state_effecter.hpp b/libpldmresponder/platform_state_effecter.hpp
index ba1c9bd..5875f13 100644
--- a/libpldmresponder/platform_state_effecter.hpp
+++ b/libpldmresponder/platform_state_effecter.hpp
@@ -143,8 +143,8 @@
}
catch (const std::out_of_range& e)
{
- std::cerr << "the effecterId does not exist. effecter id: "
- << effecterId << e.what() << '\n';
+ std::cerr << "Unknown effecter ID : " << effecterId << e.what() << '\n';
+ return PLDM_ERROR;
}
return rc;