@@ -452,7 +452,7 @@ function createPullRequest(inputs) {
452
452
}
453
453
}
454
454
catch (error) {
455
- core.setFailed(error.message );
455
+ core.setFailed(utils.getErrorMessage(error) );
456
456
}
457
457
finally {
458
458
// Remove auth and restore persisted auth config if it existed
@@ -507,6 +507,7 @@ const core = __importStar(__nccwpck_require__(2186));
507
507
const fs = __importStar(__nccwpck_require__(7147));
508
508
const path = __importStar(__nccwpck_require__(1017));
509
509
const url_1 = __nccwpck_require__(7310);
510
+ const utils = __importStar(__nccwpck_require__(918));
510
511
class GitAuthHelper {
511
512
constructor(git) {
512
513
this.extraheaderConfigPlaceholderValue = 'AUTHORIZATION: basic ***';
@@ -531,7 +532,7 @@ class GitAuthHelper {
531
532
core.info('Persisted git credentials restored');
532
533
}
533
534
catch (e) {
534
- core.warning(e );
535
+ core.warning(utils.getErrorMessage(e) );
535
536
}
536
537
}
537
538
});
@@ -942,6 +943,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
942
943
exports.GitHubHelper = void 0;
943
944
const core = __importStar(__nccwpck_require__(2186));
944
945
const octokit_client_1 = __nccwpck_require__(5040);
946
+ const utils = __importStar(__nccwpck_require__(918));
945
947
const ERROR_PR_REVIEW_FROM_AUTHOR = 'Review cannot be requested from pull request author';
946
948
class GitHubHelper {
947
949
constructor(token) {
@@ -976,8 +978,7 @@ class GitHubHelper {
976
978
};
977
979
}
978
980
catch (e) {
979
- if (e.message &&
980
- e.message.includes(`A pull request already exists for`)) {
981
+ if (utils.getErrorMessage(e).includes(`A pull request already exists for`)) {
981
982
core.info(`A pull request already exists for ${headBranch}`);
982
983
}
983
984
else {
@@ -1040,7 +1041,7 @@ class GitHubHelper {
1040
1041
yield this.octokit.rest.pulls.requestReviewers(Object.assign(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { pull_number: pull.number }), requestReviewersParams));
1041
1042
}
1042
1043
catch (e) {
1043
- if (e.message && e.message .includes(ERROR_PR_REVIEW_FROM_AUTHOR)) {
1044
+ if (utils.getErrorMessage(e) .includes(ERROR_PR_REVIEW_FROM_AUTHOR)) {
1044
1045
core.warning(ERROR_PR_REVIEW_FROM_AUTHOR);
1045
1046
}
1046
1047
else {
@@ -1124,7 +1125,7 @@ function run() {
1124
1125
yield (0, create_pull_request_1.createPullRequest)(inputs);
1125
1126
}
1126
1127
catch (error) {
1127
- core.setFailed(error.message );
1128
+ core.setFailed(utils.getErrorMessage(error) );
1128
1129
}
1129
1130
});
1130
1131
}
@@ -1192,7 +1193,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
1192
1193
return result;
1193
1194
};
1194
1195
Object.defineProperty(exports, "__esModule", ({ value: true }));
1195
- exports.fileExistsSync = exports.parseDisplayNameEmail = exports.randomString = exports.secondsSinceEpoch = exports.getRemoteUrl = exports.getRemoteDetail = exports.getRepoPath = exports.getStringAsArray = exports.getInputAsArray = void 0;
1196
+ exports.getErrorMessage = exports. fileExistsSync = exports.parseDisplayNameEmail = exports.randomString = exports.secondsSinceEpoch = exports.getRemoteUrl = exports.getRemoteDetail = exports.getRepoPath = exports.getStringAsArray = exports.getInputAsArray = void 0;
1196
1197
const core = __importStar(__nccwpck_require__(2186));
1197
1198
const fs = __importStar(__nccwpck_require__(7147));
1198
1199
const path = __importStar(__nccwpck_require__(1017));
@@ -1293,17 +1294,27 @@ function fileExistsSync(path) {
1293
1294
stats = fs.statSync(path);
1294
1295
}
1295
1296
catch (error) {
1296
- if (error.code === 'ENOENT') {
1297
+ if (hasErrorCode(error) && error.code === 'ENOENT') {
1297
1298
return false;
1298
1299
}
1299
- throw new Error(`Encountered an error when checking whether path '${path}' exists: ${error.message }`);
1300
+ throw new Error(`Encountered an error when checking whether path '${path}' exists: ${getErrorMessage( error) }`);
1300
1301
}
1301
1302
if (!stats.isDirectory()) {
1302
1303
return true;
1303
1304
}
1304
1305
return false;
1305
1306
}
1306
1307
exports.fileExistsSync = fileExistsSync;
1308
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1309
+ function hasErrorCode(error) {
1310
+ return typeof (error && error.code) === 'string';
1311
+ }
1312
+ function getErrorMessage(error) {
1313
+ if (error instanceof Error)
1314
+ return error.message;
1315
+ return String(error);
1316
+ }
1317
+ exports.getErrorMessage = getErrorMessage;
1307
1318
1308
1319
1309
1320
/***/ }),
0 commit comments