From 017007559c76d08d674a5584582403231f802cba Mon Sep 17 00:00:00 2001 From: Shubham Tiwari <64764738+tiwarishub@users.noreply.github.com> Date: Tue, 21 Jun 2022 07:22:33 +0000 Subject: [PATCH] review comment to add validation as errors handling --- packages/cache/src/cache.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/cache/src/cache.ts b/packages/cache/src/cache.ts index 00c9e84e..609c7f94 100644 --- a/packages/cache/src/cache.ts +++ b/packages/cache/src/cache.ts @@ -127,8 +127,13 @@ export async function restoreCache( return cacheEntry.cacheKey } catch (error) { - // Supress all cache related errors because caching should be optional - core.warning(`Failed to restore: ${(error as Error).message}`) + const typedError = error as Error + if (typedError.name === ValidationError.name) { + throw error + } else { + // Supress all non-validation cache related errors because caching should be optional + core.warning(`Failed to restore: ${(error as Error).message}`) + } } finally { // Try to delete the archive to save space try { @@ -225,7 +230,9 @@ export async function saveCache( await cacheHttpClient.saveCache(cacheId, archivePath, options) } catch (error) { const typedError = error as Error - if (typedError.name === ReserveCacheError.name) { + if (typedError.name === ValidationError.name) { + throw error + } else if (typedError.name === ReserveCacheError.name) { core.info(`Failed to save: ${typedError.message}`) } else { core.warning(`Failed to save: ${typedError.message}`)