Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Error message for missing config file #475

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
node_modules/
lib/
lib/
.idea
11 changes: 10 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,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:
Expand Down
11 changes: 7 additions & 4 deletions package-lock.json

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

15 changes: 11 additions & 4 deletions src/labeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,17 @@ async function getLabelGlobs(
client: ClientType,
configurationPath: string
): Promise<Map<string, StringOrMatchConfig[]>> {
const configurationContent: string = await fetchContent(
client,
configurationPath
);
let configurationContent: string;
try {
configurationContent = await fetchContent(client, configurationPath);
} catch (e: any) {
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: any = yaml.load(configurationContent);
Expand Down