add restore cache error handling

This commit is contained in:
panticmilos 2022-06-14 12:05:49 +02:00
parent 7e4abae443
commit 5d7223261b
3 changed files with 46 additions and 10 deletions

View file

@ -35,13 +35,25 @@ abstract class CacheDistributor {
core.saveState(State.CACHE_PATHS, cachePath);
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
const matchedKey = await cache.restoreCache(
cachePath,
primaryKey,
restoreKey
);
try {
const matchedKey = await cache.restoreCache(
cachePath,
primaryKey,
restoreKey
);
this.handleMatchResult(matchedKey, primaryKey);
} catch(error) {
const typedError = error as Error;
if (typedError.name === cache.ValidationError.name) {
throw error;
} else {
core.warning(typedError.message);
core.setOutput('cache-hit', false);
}
}
this.handleMatchResult(matchedKey, primaryKey);
}
public handleMatchResult(matchedKey: string | undefined, primaryKey: string) {