catch exceptions as const

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ic2b49715c7b81ac5bcfc12ff2d3b4c593cd95ce7
diff --git a/apphandler.cpp b/apphandler.cpp
index 5e67587..a20d61a 100644
--- a/apphandler.cpp
+++ b/apphandler.cpp
@@ -114,7 +114,7 @@
         objectTree =
             ipmi::getAllDbusObjects(*ctx->bus, softwareRoot, redundancyIntf);
     }
-    catch (sdbusplus::exception::exception& e)
+    catch (const sdbusplus::exception::exception& e)
     {
         log<level::ERR>("Failed to fetch redundancy object from dbus",
                         entry("INTERFACE=%s", redundancyIntf),
@@ -733,7 +733,7 @@
         {
             b = std::stoul(v, &err, 16);
         }
-        catch (std::exception& e)
+        catch (const std::exception& e)
         {
             elog<InvalidArgument>(Argument::ARGUMENT_NAME("rfc4122"),
                                   Argument::ARGUMENT_VALUE(rfc4122.c_str()));
@@ -860,7 +860,7 @@
             return ipmi::ccSuccess;
         }
     }
-    catch (std::exception& e)
+    catch (const std::exception& e)
     {
         log<level::ERR>("Failed in getting session state property",
                         entry("service=%s", service.c_str()),
@@ -926,7 +926,7 @@
             }
         }
     }
-    catch (sdbusplus::exception::exception& e)
+    catch (const sdbusplus::exception::exception& e)
     {
         log<level::ERR>("Failed to fetch object from dbus",
                         entry("INTERFACE=%s", session::sessionIntf),
@@ -1485,7 +1485,7 @@
     {
         data = nlohmann::json::parse(jsonFile, nullptr, false);
     }
-    catch (nlohmann::json::parse_error& e)
+    catch (const nlohmann::json::parse_error& e)
     {
         log<level::ERR>("Corrupted i2c white list config file",
                         entry("FILE_NAME: %s", i2cMasterWRWhitelistFile),
@@ -1556,7 +1556,7 @@
             return false;
         }
     }
-    catch (std::exception& e)
+    catch (const std::exception& e)
     {
         log<level::ERR>("I2C master write read whitelist unexpected exception",
                         entry("ERROR=%s", e.what()));
diff --git a/chassishandler.cpp b/chassishandler.cpp
index dfbe004..30ffb23 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -277,7 +277,7 @@
                   reinterpret_cast<void*>(gatewayDetails.data()));
         payload.pack(gatewayDetails);
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         commit<InternalFailure>();
         rc = -1;
@@ -552,7 +552,7 @@
         log<level::DEBUG>("Network configuration changed",
                           entry("NETWORKCONFIG=%s", hostNetworkConfig.c_str()));
     }
-    catch (sdbusplus::exception_t& e)
+    catch (const sdbusplus::exception_t& e)
     {
         commit<InternalFailure>();
         log<level::ERR>("Error in  ipmiChassisSetSysBootOptions call");
@@ -626,7 +626,7 @@
             ipmi::getAllDbusProperties(bus, chassisCapObject.second,
                                        chassisCapObject.first, chassisCapIntf);
     }
-    catch (std::exception& e)
+    catch (const std::exception& e)
     {
         log<level::ERR>("Failed to fetch Chassis Capability properties",
                         entry("ERROR=%s", e.what()));
@@ -804,7 +804,7 @@
                               chassisCapObject.first, chassisCapIntf,
                               chassisBridgeDevAddrProp, bridgeDeviceAddr);
     }
-    catch (std::exception& e)
+    catch (const std::exception& e)
     {
         log<level::ERR>(e.what());
         return ipmi::responseUnspecifiedError();
@@ -892,7 +892,7 @@
         ipmi::setDbusProperty(*busp, service, nmiSourceObjPath, nmiSourceIntf,
                               "Enabled", value);
     }
-    catch (std::exception& e)
+    catch (const std::exception& e)
     {
         log<level::ERR>("Failed to trigger NMI_OUT",
                         entry("EXCEPTION=%s", e.what()));
@@ -1046,7 +1046,7 @@
                                                     buttonIntf, "Enabled");
         buttonDisabled = !std::get<bool>(enabled);
     }
-    catch (sdbusplus::exception::exception& e)
+    catch (const sdbusplus::exception::exception& e)
     {
         log<level::ERR>("Fail to get button Enabled property",
                         entry("PATH=%s", buttonPath.c_str()),
@@ -2039,7 +2039,7 @@
                           uint2_t{}, uint8_t{}, uint8_t{}, uint8_t{});
             return ipmi::responseSuccess(std::move(response));
         }
-        catch (InternalFailure& e)
+        catch (const InternalFailure& e)
         {
             cache::objectsPtr.reset();
             report<InternalFailure>();
@@ -2237,7 +2237,7 @@
                 return ipmi::responseInvalidFieldRequest();
             }
         }
-        catch (sdbusplus::exception_t& e)
+        catch (const sdbusplus::exception_t& e)
         {
             objectsPtr.reset();
             report<InternalFailure>();
@@ -2345,7 +2345,7 @@
         return ipmi::responseSuccess(static_cast<uint8_t>(poh::minutesPerCount),
                                      getPOHCounter());
     }
-    catch (std::exception& e)
+    catch (const std::exception& e)
     {
         log<level::ERR>(e.what());
         return ipmi::responseUnspecifiedError();
@@ -2408,7 +2408,7 @@
             return ipmi::responseUnspecifiedError();
         }
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         chassis::internal::cache::objectsPtr.reset();
         report<InternalFailure>();
diff --git a/dbus-sdr/sdrutils.cpp b/dbus-sdr/sdrutils.cpp
index 7788050..ede14bf 100644
--- a/dbus-sdr/sdrutils.cpp
+++ b/dbus-sdr/sdrutils.cpp
@@ -73,7 +73,7 @@
             auto mapperReply = dbus->call(mapperCall);
             mapperReply.read(sensorTreePartial);
         }
-        catch (sdbusplus::exception_t& e)
+        catch (const sdbusplus::exception_t& e)
         {
             phosphor::logging::log<phosphor::logging::level::ERR>(
                 "fail to update subtree",
@@ -264,7 +264,7 @@
     {
         return sensorNumMapPtr->right.at(path);
     }
-    catch (std::out_of_range& e)
+    catch (const std::out_of_range& e)
     {
         phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
         return invalidSensorNumber;
@@ -298,7 +298,7 @@
     {
         return sensorNumMapPtr->left.at(sensorNum);
     }
-    catch (std::out_of_range& e)
+    catch (const std::out_of_range& e)
     {
         phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
         return std::string();
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index 7a2cbd0..b07da61 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -1098,7 +1098,7 @@
     {
         thresholdData = getIPMIThresholds(sensorMap);
     }
-    catch (std::exception&)
+    catch (const std::exception&)
     {
         return ipmi::responseResponseError();
     }
@@ -1628,7 +1628,7 @@
     {
         thresholdData = getIPMIThresholds(sensorMap);
     }
-    catch (std::exception&)
+    catch (const std::exception&)
     {
         phosphor::logging::log<phosphor::logging::level::ERR>(
             "getSensorDataRecord: getIPMIThresholds error");
diff --git a/dbus-sdr/storagecommands.cpp b/dbus-sdr/storagecommands.cpp
index 5926615..0ead858 100644
--- a/dbus-sdr/storagecommands.cpp
+++ b/dbus-sdr/storagecommands.cpp
@@ -141,7 +141,7 @@
     {
         sdbusplus::message::message writeFruResp = dbus->call(writeFru);
     }
-    catch (sdbusplus::exception_t&)
+    catch (const sdbusplus::exception_t&)
     {
         // todo: log sel?
         phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -318,7 +318,7 @@
                                 {
                                     message.read(path, object);
                                 }
-                                catch (sdbusplus::exception_t&)
+                                catch (const sdbusplus::exception_t&)
                                 {
                                     return;
                                 }
@@ -344,7 +344,7 @@
                                 {
                                     message.read(path, interfaces);
                                 }
-                                catch (sdbusplus::exception_t&)
+                                catch (const sdbusplus::exception_t&)
                                 {
                                     return;
                                 }
@@ -843,12 +843,12 @@
             data.push_back(static_cast<uint8_t>(
                 std::stoul(hexStr.substr(i, 2), nullptr, 16)));
         }
-        catch (std::invalid_argument& e)
+        catch (const std::invalid_argument& e)
         {
             phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
             return -1;
         }
-        catch (std::out_of_range& e)
+        catch (const std::out_of_range& e)
         {
             phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
             return -1;
@@ -1158,7 +1158,7 @@
     {
         sdbusplus::message::message reloadResponse = dbus->call(rsyslogReload);
     }
-    catch (sdbusplus::exception_t& e)
+    catch (const sdbusplus::exception_t& e)
     {
         phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
     }
diff --git a/dcmihandler.cpp b/dcmihandler.cpp
index cc8b6d0..2ab02f3 100644
--- a/dcmihandler.cpp
+++ b/dcmihandler.cpp
@@ -323,7 +323,7 @@
         pcapValue = dcmi::getPcap(sdbus);
         pcapEnable = dcmi::getPcapEnabled(sdbus);
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         *data_len = 0;
         return IPMI_CC_UNSPECIFIED_ERROR;
@@ -378,7 +378,7 @@
     {
         dcmi::setPcap(sdbus, requestData->powerLimit);
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         *data_len = 0;
         return IPMI_CC_UNSPECIFIED_ERROR;
@@ -412,7 +412,7 @@
         dcmi::setPcapEnable(sdbus,
                             static_cast<bool>(requestData->powerLimitAction));
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         *data_len = 0;
         return IPMI_CC_UNSPECIFIED_ERROR;
@@ -451,7 +451,7 @@
     {
         assetTag = dcmi::readAssetTag();
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         *data_len = 0;
         return IPMI_CC_UNSPECIFIED_ERROR;
@@ -538,7 +538,7 @@
 
         return IPMI_CC_OK;
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         *data_len = 0;
         return IPMI_CC_UNSPECIFIED_ERROR;
@@ -567,7 +567,7 @@
     {
         hostName = dcmi::getHostName();
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         return IPMI_CC_UNSPECIFIED_ERROR;
     }
@@ -642,7 +642,7 @@
                                   std::string(newCtrlIdStr.data()));
         }
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         *data_len = 0;
         return IPMI_CC_UNSPECIFIED_ERROR;
@@ -828,7 +828,7 @@
             service =
                 ipmi::getService(bus, "xyz.openbmc_project.Sensor.Value", path);
         }
-        catch (std::exception& e)
+        catch (const std::exception& e)
         {
             log<level::DEBUG>(e.what());
             return std::make_tuple(response, numInstances);
@@ -893,7 +893,7 @@
             r.sign = sign;
             response.push_back(r);
         }
-        catch (std::exception& e)
+        catch (const std::exception& e)
         {
             log<level::DEBUG>(e.what());
             continue;
@@ -962,7 +962,7 @@
         }
         responseData->numDataSets = temps.size();
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         return IPMI_CC_UNSPECIFIED_ERROR;
     }
@@ -1021,7 +1021,7 @@
         // formula Value * 10^Scale.
         power = value * std::pow(10, scale);
     }
-    catch (std::exception& e)
+    catch (const std::exception& e)
     {
         log<level::INFO>("Failure to read power value from D-Bus object",
                          entry("OBJECT_PATH=%s", objectPath.c_str()),
@@ -1091,7 +1091,7 @@
                 return IPMI_CC_INVALID;
         }
     }
-    catch (std::exception& e)
+    catch (const std::exception& e)
     {
         log<level::ERR>(e.what());
         return IPMI_CC_UNSPECIFIED_ERROR;
@@ -1157,7 +1157,7 @@
                 return IPMI_CC_INVALID;
         }
     }
-    catch (std::exception& e)
+    catch (const std::exception& e)
     {
         log<level::ERR>(e.what());
         return IPMI_CC_UNSPECIFIED_ERROR;
@@ -1191,7 +1191,7 @@
     {
         power = getPowerReading(bus);
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         log<level::ERR>("Error in reading power sensor value",
                         entry("INTERFACE=%s", SENSOR_VALUE_INTF),
@@ -1294,7 +1294,7 @@
             Response response = createFromJson(reading);
             responses.push_back(response);
         }
-        catch (std::exception& e)
+        catch (const std::exception& e)
         {
             log<level::DEBUG>(e.what());
             continue;
@@ -1374,7 +1374,7 @@
         }
         responseData->numRecords = sensors.size();
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         return IPMI_CC_UNSPECIFIED_ERROR;
     }
diff --git a/globalhandler.cpp b/globalhandler.cpp
index c192cbb..2561e08 100644
--- a/globalhandler.cpp
+++ b/globalhandler.cpp
@@ -42,7 +42,7 @@
     {
         resetBMC();
     }
-    catch (std::exception& e)
+    catch (const std::exception& e)
     {
         log<level::ERR>(e.what());
         return ipmi::responseUnspecifiedError();
diff --git a/ipmi_fru_info_area.cpp b/ipmi_fru_info_area.cpp
index ca06f5b..155e88b 100644
--- a/ipmi_fru_info_area.cpp
+++ b/ipmi_fru_info_area.cpp
@@ -141,7 +141,7 @@
         {
             chassisType = std::stoi(value);
         }
-        catch (std::exception& e)
+        catch (const std::exception& e)
         {
             log<level::ERR>("Could not parse chassis type",
                             entry("VALUE=%s", value.c_str()),
diff --git a/ipmid-new.cpp b/ipmid-new.cpp
index be809cf..7f558cd 100644
--- a/ipmid-new.cpp
+++ b/ipmid-new.cpp
@@ -598,7 +598,7 @@
         {
             addr = dlopen(name.c_str(), RTLD_NOW);
         }
-        catch (std::exception& e)
+        catch (const std::exception& e)
         {
             log<level::ERR>("ERROR opening IPMI provider",
                             entry("PROVIDER=%s", name.c_str()),
diff --git a/libipmid/utils.cpp b/libipmid/utils.cpp
index 8d225ee..0f6d0dd 100644
--- a/libipmid/utils.cpp
+++ b/libipmid/utils.cpp
@@ -326,7 +326,7 @@
                                            "Delete");
         }
     }
-    catch (sdbusplus::exception::exception& e)
+    catch (const sdbusplus::exception::exception& e)
     {
         log<level::INFO>("sdbusplus exception - Unable to delete the objects",
                          entry("ERROR=%s", e.what()),
diff --git a/sensordatahandler.cpp b/sensordatahandler.cpp
index fc74b8f..4665f38 100644
--- a/sensordatahandler.cpp
+++ b/sensordatahandler.cpp
@@ -99,7 +99,7 @@
             return IPMI_CC_UNSPECIFIED_ERROR;
         }
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         commit<InternalFailure>();
         return IPMI_CC_UNSPECIFIED_ERROR;
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index ed02c62..7c5aa06 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -387,7 +387,7 @@
         auto ipmiRC = iter->second.updateFunc(cmdData, iter->second);
         return ipmi::response(ipmiRC);
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         log<level::ERR>("Set sensor failed",
                         entry("SENSOR_NUM=%d", sensorNumber));
@@ -1094,7 +1094,7 @@
     {
         dbus.call(writeSEL);
     }
-    catch (sdbusplus::exception_t& e)
+    catch (const sdbusplus::exception_t& e)
     {
         phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
         return IPMI_CC_UNSPECIFIED_ERROR;
diff --git a/storagehandler.cpp b/storagehandler.cpp
index eecc18b..6c00325 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -126,7 +126,7 @@
             addTimeStamp = static_cast<uint32_t>(
                 (ipmi::sel::getEntryTimeStamp(cache::paths.back()).count()));
         }
-        catch (InternalFailure& e)
+        catch (const InternalFailure& e)
         {
         }
         catch (const std::runtime_error& e)
@@ -208,7 +208,7 @@
     {
         record = ipmi::sel::convertLogEntrytoSEL(*iter);
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         *data_len = 0;
         return IPMI_CC_UNSPECIFIED_ERROR;
@@ -504,7 +504,7 @@
         reply.read(value);
         bmc_time_usec = std::get<uint64_t>(value);
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         log<level::ERR>(e.what());
         return ipmi::responseUnspecifiedError();
@@ -556,7 +556,7 @@
             return ipmi::responseUnspecifiedError();
         }
     }
-    catch (InternalFailure& e)
+    catch (const InternalFailure& e)
     {
         log<level::ERR>(e.what());
         return ipmi::responseUnspecifiedError();
diff --git a/user_channel/channel_mgmt.cpp b/user_channel/channel_mgmt.cpp
index a0fbcb7..41b477d 100644
--- a/user_channel/channel_mgmt.cpp
+++ b/user_channel/channel_mgmt.cpp
@@ -806,7 +806,7 @@
     {
         data = Json::parse(jsonFile, nullptr, false);
     }
-    catch (Json::parse_error& e)
+    catch (const Json::parse_error& e)
     {
         log<level::DEBUG>("Corrupted channel config.",
                           entry("MSG=%s", e.what()));
diff --git a/user_channel/cipher_mgmt.cpp b/user_channel/cipher_mgmt.cpp
index ca9c2d4..8355865 100644
--- a/user_channel/cipher_mgmt.cpp
+++ b/user_channel/cipher_mgmt.cpp
@@ -106,7 +106,7 @@
     {
         data = Json::parse(jsonFile, nullptr, false);
     }
-    catch (Json::parse_error& e)
+    catch (const Json::parse_error& e)
     {
         log<level::ERR>("Corrupted cipher suite privilege levels config file.",
                         entry("MSG: %s", e.what()));
diff --git a/user_channel/user_mgmt.cpp b/user_channel/user_mgmt.cpp
index 6ae90fc..b36a2e6 100644
--- a/user_channel/user_mgmt.cpp
+++ b/user_channel/user_mgmt.cpp
@@ -1297,7 +1297,7 @@
                 }
             }
         }
-        catch (Json::out_of_range& e)
+        catch (const Json::out_of_range& e)
         {
             // Key not found in 'userInfo'; possibly an old JSON file. Use
             // default values for all payloads, and SOL payload default is true.