Skip to content

Commit 6b58086

Browse files
authored
Merge pull request #628 from peter-evans/fix-any
Replace use of any type
2 parents ebb3089 + 52f0597 commit 6b58086

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

dist/index.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function run() {
117117
}
118118
catch (error) {
119119
core.debug((0, util_1.inspect)(error));
120-
core.setFailed(error.message);
120+
core.setFailed(utils.getErrorMessage(error));
121121
}
122122
});
123123
}
@@ -151,7 +151,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
151151
return result;
152152
};
153153
Object.defineProperty(exports, "__esModule", ({ value: true }));
154-
exports.getStringAsArray = exports.getInputAsArray = void 0;
154+
exports.getErrorMessage = exports.getStringAsArray = exports.getInputAsArray = void 0;
155155
const core = __importStar(__nccwpck_require__(2186));
156156
function getInputAsArray(name, options) {
157157
return getStringAsArray(core.getInput(name, options));
@@ -164,6 +164,12 @@ function getStringAsArray(str) {
164164
.filter(x => x !== '');
165165
}
166166
exports.getStringAsArray = getStringAsArray;
167+
function getErrorMessage(error) {
168+
if (error instanceof Error)
169+
return error.message;
170+
return String(error);
171+
}
172+
exports.getErrorMessage = getErrorMessage;
167173

168174

169175
/***/ }),

src/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ async function run(): Promise<void> {
8181
} else {
8282
core.info(`File not found at path '${inputs.contentFilepath}'`)
8383
}
84-
} catch (error: any) {
84+
} catch (error) {
8585
core.debug(inspect(error))
86-
core.setFailed(error.message)
86+
core.setFailed(utils.getErrorMessage(error))
8787
}
8888
}
8989

src/utils.ts

+5
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ export function getStringAsArray(str: string): string[] {
1313
.map(s => s.trim())
1414
.filter(x => x !== '')
1515
}
16+
17+
export function getErrorMessage(error: unknown) {
18+
if (error instanceof Error) return error.message
19+
return String(error)
20+
}

0 commit comments

Comments
 (0)