catch exceptions as const
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Id1b5054d3147c39d98309bc11ed7016d6909e2a6
diff --git a/control/fanctl.cpp b/control/fanctl.cpp
index 07ae84b..0061094 100644
--- a/control/fanctl.cpp
+++ b/control/fanctl.cpp
@@ -302,7 +302,7 @@
val = "false";
}
}
- catch (phosphor::fan::util::DBusPropertyError&)
+ catch (const phosphor::fan::util::DBusPropertyError&)
{
val = "Unknown";
}
@@ -327,7 +327,7 @@
val = "false";
}
}
- catch (phosphor::fan::util::DBusPropertyError&)
+ catch (const phosphor::fan::util::DBusPropertyError&)
{
val = "Unknown";
}
diff --git a/control/json/dbus_zone.cpp b/control/json/dbus_zone.cpp
index af37108..d4b6d23 100644
--- a/control/json/dbus_zone.cpp
+++ b/control/json/dbus_zone.cpp
@@ -85,7 +85,7 @@
iArch(current);
}
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
// Include possible exception when removing file, otherwise ec = 0
std::error_code ec;
diff --git a/control/json/manager.cpp b/control/json/manager.cpp
index 4315cf1..691c11f 100644
--- a/control/json/manager.cpp
+++ b/control/json/manager.cpp
@@ -80,7 +80,7 @@
_loadAllowed = true;
load();
}
- catch (std::runtime_error& re)
+ catch (const std::runtime_error& re)
{
// Restore saved available and active profiles
_loadAllowed = false;
diff --git a/control/main.cpp b/control/main.cpp
index 9eec2c5..81c368b 100644
--- a/control/main.cpp
+++ b/control/main.cpp
@@ -98,13 +98,13 @@
}
// Log the useful metadata on these exceptions and let the app
// return 1 so it is restarted without a core dump.
- catch (phosphor::fan::util::DBusServiceError& e)
+ catch (const phosphor::fan::util::DBusServiceError& e)
{
log<level::ERR>("Uncaught DBus service lookup failure exception",
entry("PATH=%s", e.path.c_str()),
entry("INTERFACE=%s", e.interface.c_str()));
}
- catch (phosphor::fan::util::DBusMethodError& e)
+ catch (const phosphor::fan::util::DBusMethodError& e)
{
log<level::ERR>("Uncaught DBus method failure exception",
entry("BUSNAME=%s", e.busName.c_str()),
@@ -112,7 +112,7 @@
entry("INTERFACE=%s", e.interface.c_str()),
entry("METHOD=%s", e.method.c_str()));
}
- catch (phosphor::fan::util::DBusPropertyError& e)
+ catch (const phosphor::fan::util::DBusPropertyError& e)
{
log<level::ERR>("Uncaught DBus property access failure exception",
entry("BUSNAME=%s", e.busName.c_str()),
diff --git a/control/zone.cpp b/control/zone.cpp
index 9efb0c7..49ee35c 100644
--- a/control/zone.cpp
+++ b/control/zone.cpp
@@ -589,7 +589,7 @@
iArch(current);
}
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
log<level::ERR>(e.what());
fs::remove(path);
diff --git a/cooling-type/main.cpp b/cooling-type/main.cpp
index 5348afa..183a7f6 100644
--- a/cooling-type/main.cpp
+++ b/cooling-type/main.cpp
@@ -68,7 +68,7 @@
coolingType.updateInventory(objpath);
rc = 0;
}
- catch (DBusMethodError& dme)
+ catch (const DBusMethodError& dme)
{
log<level::ERR>(
fmt::format("Uncaught DBus method failure exception "
@@ -79,7 +79,7 @@
dme.busName, dme.path, dme.interface, dme.method)
.c_str());
}
- catch (std::exception& err)
+ catch (const std::exception& err)
{
log<phosphor::logging::level::ERR>(err.what());
}
diff --git a/json_config.hpp b/json_config.hpp
index 6322e6e..60e535d 100644
--- a/json_config.hpp
+++ b/json_config.hpp
@@ -283,7 +283,7 @@
// Enable ignoring `//` or `/* */` comments
jsonConf = json::parse(file, nullptr, true, true);
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
log<level::ERR>(
fmt::format(
diff --git a/monitor/system.cpp b/monitor/system.cpp
index aa80bd4..f3863b0 100644
--- a/monitor/system.cpp
+++ b/monitor/system.cpp
@@ -183,7 +183,7 @@
_sensorMatch.clear();
subscribeSensorsToServices();
}
- catch (std::runtime_error& re)
+ catch (const std::runtime_error& re)
{
log<level::ERR>("Error reloading config, no config changes made",
entry("LOAD_ERROR=%s", re.what()));
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 9bf9932..0c2d4d9 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -61,7 +61,7 @@
value =
util::SDBusPlus::getProperty<T>(bus, path, interface, propertyName);
}
- catch (std::exception& e)
+ catch (const std::exception& e)
{
phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
}
@@ -102,7 +102,7 @@
util::OPERATIONAL_STATUS_INTF, util::FUNCTIONAL_PROPERTY);
}
}
- catch (util::DBusError& e)
+ catch (const util::DBusError& e)
{
log<level::DEBUG>(e.what());
}
diff --git a/presence/json_parser.cpp b/presence/json_parser.cpp
index bfaedaf..d4f121f 100644
--- a/presence/json_parser.cpp
+++ b/presence/json_parser.cpp
@@ -91,7 +91,7 @@
}
log<level::INFO>("Configuration loaded successfully");
}
- catch (std::runtime_error& re)
+ catch (const std::runtime_error& re)
{
log<level::ERR>("Error loading config, no config changes made",
entry("LOAD_ERROR=%s", re.what()));
diff --git a/presence/tach.cpp b/presence/tach.cpp
index 7304676..4c2dc14 100644
--- a/presence/tach.cpp
+++ b/presence/tach.cpp
@@ -69,7 +69,7 @@
std::get<double>(s) = util::SDBusPlus::getProperty<double>(
tachPath, tachIface, tachProperty);
}
- catch (std::exception&)
+ catch (const std::exception&)
{
// Assume not spinning.
diff --git a/sdbusplus.hpp b/sdbusplus.hpp
index 6787f49..909fbc3 100644
--- a/sdbusplus.hpp
+++ b/sdbusplus.hpp
@@ -306,7 +306,7 @@
}
return mapperResp.begin()->first;
}
- catch (DBusMethodError& e)
+ catch (const DBusMethodError& e)
{
throw DBusServiceError{path, interface};
}