mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2025-08-22 10:29:06 +08:00
review comment to add validation as errors handling
This commit is contained in:
parent
7b1bc1f56a
commit
017007559c
13
packages/cache/src/cache.ts
vendored
13
packages/cache/src/cache.ts
vendored
@ -127,8 +127,13 @@ export async function restoreCache(
|
|||||||
|
|
||||||
return cacheEntry.cacheKey
|
return cacheEntry.cacheKey
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Supress all cache related errors because caching should be optional
|
const typedError = error as Error
|
||||||
core.warning(`Failed to restore: ${(error as Error).message}`)
|
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 {
|
} finally {
|
||||||
// Try to delete the archive to save space
|
// Try to delete the archive to save space
|
||||||
try {
|
try {
|
||||||
@ -225,7 +230,9 @@ export async function saveCache(
|
|||||||
await cacheHttpClient.saveCache(cacheId, archivePath, options)
|
await cacheHttpClient.saveCache(cacheId, archivePath, options)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const typedError = error as 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}`)
|
core.info(`Failed to save: ${typedError.message}`)
|
||||||
} else {
|
} else {
|
||||||
core.warning(`Failed to save: ${typedError.message}`)
|
core.warning(`Failed to save: ${typedError.message}`)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user