mirror of
https://github.com/actions/checkout.git
synced 2025-04-01 22:10:06 +02:00
Add error wrapping
This commit is contained in:
parent
8f0470a08c
commit
0e3d9a88f6
2 changed files with 34 additions and 13 deletions
11
dist/index.js
vendored
11
dist/index.js
vendored
|
@ -1453,6 +1453,7 @@ const path = __importStar(__nccwpck_require__(1017));
|
||||||
const retryHelper = __importStar(__nccwpck_require__(2155));
|
const retryHelper = __importStar(__nccwpck_require__(2155));
|
||||||
const toolCache = __importStar(__nccwpck_require__(7784));
|
const toolCache = __importStar(__nccwpck_require__(7784));
|
||||||
const v4_1 = __importDefault(__nccwpck_require__(824));
|
const v4_1 = __importDefault(__nccwpck_require__(824));
|
||||||
|
const request_error_1 = __nccwpck_require__(537);
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
function downloadRepository(authToken, owner, repo, ref, commit, repositoryPath, baseUrl) {
|
function downloadRepository(authToken, owner, repo, ref, commit, repositoryPath, baseUrl) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
@ -1549,12 +1550,22 @@ function downloadArchive(authToken, owner, repo, ref, commit, baseUrl) {
|
||||||
const download = IS_WINDOWS
|
const download = IS_WINDOWS
|
||||||
? octokit.rest.repos.downloadZipballArchive
|
? octokit.rest.repos.downloadZipballArchive
|
||||||
: octokit.rest.repos.downloadTarballArchive;
|
: octokit.rest.repos.downloadTarballArchive;
|
||||||
|
try {
|
||||||
const response = yield download({
|
const response = yield download({
|
||||||
owner: owner,
|
owner: owner,
|
||||||
repo: repo,
|
repo: repo,
|
||||||
ref: commit || ref
|
ref: commit || ref
|
||||||
});
|
});
|
||||||
return Buffer.from(response.data); // response.data is ArrayBuffer
|
return Buffer.from(response.data); // response.data is ArrayBuffer
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
if (error instanceof request_error_1.RequestError) {
|
||||||
|
throw new Error(`Unexpected response from GitHub API. Status: ${error.status}, Data: ${error.message}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import * as path from 'path'
|
||||||
import * as retryHelper from './retry-helper'
|
import * as retryHelper from './retry-helper'
|
||||||
import * as toolCache from '@actions/tool-cache'
|
import * as toolCache from '@actions/tool-cache'
|
||||||
import {default as uuid} from 'uuid/v4'
|
import {default as uuid} from 'uuid/v4'
|
||||||
|
import { RequestError } from '@octokit/request-error';
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32'
|
const IS_WINDOWS = process.platform === 'win32'
|
||||||
|
|
||||||
|
@ -129,11 +130,20 @@ async function downloadArchive(
|
||||||
const download = IS_WINDOWS
|
const download = IS_WINDOWS
|
||||||
? octokit.rest.repos.downloadZipballArchive
|
? octokit.rest.repos.downloadZipballArchive
|
||||||
: octokit.rest.repos.downloadTarballArchive
|
: octokit.rest.repos.downloadTarballArchive
|
||||||
|
try {
|
||||||
const response = await download({
|
const response = await download({
|
||||||
owner: owner,
|
owner: owner,
|
||||||
repo: repo,
|
repo: repo,
|
||||||
ref: commit || ref
|
ref: commit || ref
|
||||||
})
|
});
|
||||||
|
|
||||||
return Buffer.from(response.data as ArrayBuffer) // response.data is ArrayBuffer
|
return Buffer.from(response.data as ArrayBuffer) // response.data is ArrayBuffer
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof RequestError) {
|
||||||
|
throw new Error(
|
||||||
|
`Unexpected response from GitHub API. Status: ${error.status}, Data: ${error.message}`
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue