diff --git a/src/device-utils.ts b/src/device-utils.ts index 8bd7a1914..312503452 100644 --- a/src/device-utils.ts +++ b/src/device-utils.ts @@ -146,10 +146,17 @@ function getStorage() { * @returns number */ export async function getUtilizationTime(udid: string) { - const value = await getStorage().getItem(udid); - if (value !== undefined) { - return value; + try { + const value = await getStorage().getItem(udid); + if (value !== undefined && value && !isNaN(value)) { + return value; + } else { + throw `Custom Exception: Utilizaiton time in cache is corrupted. Value = '${value}'.`; + } + } catch (err) { + logger.error(`Failed to fetch Utilization Time \n ${err}`); } + return 0; }