Skip to content

Commit 4d2108b

Browse files
committed
Improved error logging around GetEpochTS()
1 parent f629326 commit 4d2108b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

examples/energy-management-app/energy-management-common/src/EnergyEvseDelegateImpl.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -1510,9 +1510,12 @@ void EvseSession::StartSession(int64_t chargingMeterValue, int64_t dischargingMe
15101510
{
15111511
/* Get Timestamp */
15121512
uint32_t chipEpoch = 0;
1513-
if (GetEpochTS(chipEpoch) != CHIP_NO_ERROR)
1513+
CHIP_ERROR err = GetEpochTS(chipEpoch);
1514+
if (err != CHIP_NO_ERROR)
15141515
{
1515-
ChipLogError(AppServer, "EVSE: Failed to get timestamp when starting session");
1516+
/* Note that the error will be also be logged inside GetErrorTS() -
1517+
* adding context here to help debugging */
1518+
ChipLogError(AppServer, "EVSE: Unable to get current time when starting session - err:%" CHIP_ERROR_FORMAT, err.Format());
15161519
return;
15171520
}
15181521
mStartTime = chipEpoch;
@@ -1556,9 +1559,13 @@ void EvseSession::RecalculateSessionDuration()
15561559
{
15571560
/* Get Timestamp */
15581561
uint32_t chipEpoch = 0;
1559-
if (GetEpochTS(chipEpoch) != CHIP_NO_ERROR)
1562+
CHIP_ERROR err = GetEpochTS(chipEpoch);
1563+
if (err != CHIP_NO_ERROR)
15601564
{
1561-
ChipLogError(AppServer, "EVSE: Failed to get timestamp when updating session duration");
1565+
/* Note that the error will be also be logged inside GetErrorTS() -
1566+
* adding context here to help debugging */
1567+
ChipLogError(AppServer, "EVSE: Unable to get current time when updating session duration - err:%" CHIP_ERROR_FORMAT,
1568+
err.Format());
15621569
return;
15631570
}
15641571

0 commit comments

Comments
 (0)