Improved Error message for missing config file (#475)

* error message for missing config

* chore: formatting and index js

* chore: update json5

* changes from cr

Co-authored-by: AndreiLobanovich <andreilobanovich@github.com>

* chore: recreate dist.js

* chore: revert package-lock

* chore: newline fix

---------

Co-authored-by: AndreiLobanovich <andreilobanovich@github.com>
This commit is contained in:
Lukas Hennies
2023-06-30 12:09:04 +02:00
committed by GitHub
parent 0967ca812e
commit e3c0d9b6cc
3 changed files with 23 additions and 6 deletions

11
dist/index.js vendored
View File

@@ -138,7 +138,16 @@ function getChangedFiles(client, prNumber) {
}
function getLabelGlobs(client, configurationPath) {
return __awaiter(this, void 0, void 0, function* () {
const configurationContent = yield fetchContent(client, configurationPath);
let configurationContent;
try {
configurationContent = yield fetchContent(client, configurationPath);
}
catch (e) {
if (e.name == 'HttpError' || e.name == 'NotFound') {
core.warning(`The config file was not found at ${configurationPath}. Make sure it exists and that this action has the correct access rights.`);
}
throw e;
}
// loads (hopefully) a `{[label:string]: string | StringOrMatchConfig[]}`, but is `any`:
const configObject = yaml.load(configurationContent);
// transform `any` => `Map<string,StringOrMatchConfig[]>` or throw if yaml is malformed: