mirror of
https://github.com/actions/cache.git
synced 2024-12-26 19:43:04 +07:00
Turning error from any to unknown
This commit is contained in:
parent
cab6d27614
commit
f2d5621efc
@ -4,6 +4,11 @@ import * as core from "@actions/core";
|
|||||||
import { Events, Inputs, State } from "./constants";
|
import { Events, Inputs, State } from "./constants";
|
||||||
import * as utils from "./utils/actionUtils";
|
import * as utils from "./utils/actionUtils";
|
||||||
|
|
||||||
|
interface RestoreError {
|
||||||
|
name: string;
|
||||||
|
message: string;
|
||||||
|
}
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
if (!utils.isCacheFeatureAvailable()) {
|
if (!utils.isCacheFeatureAvailable()) {
|
||||||
@ -52,16 +57,17 @@ async function run(): Promise<void> {
|
|||||||
utils.setCacheHitOutput(isExactKeyMatch);
|
utils.setCacheHitOutput(isExactKeyMatch);
|
||||||
|
|
||||||
core.info(`Cache restored from key: ${cacheKey}`);
|
core.info(`Cache restored from key: ${cacheKey}`);
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
if (error.name === cache.ValidationError.name) {
|
const typedError = error as Error;
|
||||||
|
if (typedError.name === cache.ValidationError.name) {
|
||||||
throw error;
|
throw error;
|
||||||
} else {
|
} else {
|
||||||
utils.logWarning(error.message);
|
utils.logWarning(typedError.message);
|
||||||
utils.setCacheHitOutput(false);
|
utils.setCacheHitOutput(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
core.setFailed(error.message);
|
core.setFailed((error as Error ).message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
src/save.ts
15
src/save.ts
@ -49,17 +49,18 @@ async function run(): Promise<void> {
|
|||||||
uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
|
uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
|
||||||
});
|
});
|
||||||
core.info(`Cache saved with key: ${primaryKey}`);
|
core.info(`Cache saved with key: ${primaryKey}`);
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
if (error.name === cache.ValidationError.name) {
|
const typedError = error as Error;
|
||||||
|
if (typedError.name === cache.ValidationError.name) {
|
||||||
throw error;
|
throw error;
|
||||||
} else if (error.name === cache.ReserveCacheError.name) {
|
} else if (typedError.name === cache.ReserveCacheError.name) {
|
||||||
core.info(error.message);
|
core.info(typedError.message);
|
||||||
} else {
|
} else {
|
||||||
utils.logWarning(error.message);
|
utils.logWarning(typedError.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
utils.logWarning(error.message);
|
utils.logWarning((error as Error).message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user