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

chore: improve error message if script could not be loaded #70

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions bin/commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,16 @@ const runCommand = {
try {
scriptModule = await import(path);
} catch (error) {
throw new Error(
`[octoherd] ${path} does not exist or is not an ES Module`
);
if (error.code === 'ERR_MODULE_NOT_FOUND') {
throw new Error(
`[octoherd] ${path} does not exist`
);
}

const err = new Error(
`[octoherd] ${error}\n at ${path}`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels hackish, but adding the path (so it looks like a proper callstack) may helps to communicate the actual issue.

)
throw err;
}

if (!scriptModule.script) {
Expand Down