Visitar URL original
fix: report unexpected cache save failures by eifinger · Pull Request #896 · astral-sh/setup-uv · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions dist/save-cache/index.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions src/save-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ import {
import { STATE_UV_PATH, STATE_UV_VERSION } from "./utils/constants";
import { loadInputs, type SetupInputs } from "./utils/inputs";

function formatUnexpectedFailure(error: unknown): string {
if (error instanceof Error) {
return error.stack ?? error.message;
}
return String(error);
}

function failUnexpectedly(event: string, error: unknown): never {
core.setFailed(`${event}: ${formatUnexpectedFailure(error)}`);
process.exit(1);
}

process.on("uncaughtException", (error) => {
failUnexpectedly("Uncaught exception", error);
});

process.on("unhandledRejection", (reason) => {
failUnexpectedly("Unhandled promise rejection", reason);
});

export async function run(): Promise<void> {
try {
const inputs = loadInputs();
Expand Down
Loading