Skip to content

Commit

Permalink
Improve error message when workflow file doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Mercer committed Dec 21, 2022
1 parent 8b9e982 commit e9ff99b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
11 changes: 10 additions & 1 deletion lib/workflow.js

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

2 changes: 1 addition & 1 deletion lib/workflow.js.map

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

12 changes: 11 additions & 1 deletion src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,17 @@ export async function getWorkflow(): Promise<Workflow> {
relativePath
);

return yaml.load(fs.readFileSync(absolutePath, "utf-8")) as Workflow;
try {
return yaml.load(fs.readFileSync(absolutePath, "utf-8")) as Workflow;
} catch (e) {
if (e instanceof Error && e["code"] === "ENOENT") {
throw new Error(
`Unable to load code scanning workflow from ${absolutePath}. This can happen if the currently ` +
"running workflow checks out a branch that doesn't contain the corresponding workflow file."
);
}
throw e;
}
}

/**
Expand Down

0 comments on commit e9ff99b

Please sign in to comment.