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

Conversation

stefanbuck
Copy link
Member

Today, one of my scripts had a syntax error and it took me several minutes to find out the actual root cause.

If script is unwell formed

Before

Error: [octoherd] /Users/stefanb/playground/octoherd-hello.js does not exist or is not an ES Module
    at file:///Users/stefanb/code/octoherd-cli/bin/commands/run.js:87:17

After

Error: [octoherd] SyntaxError: Unexpected identifier
    at /Users/stefanb/playground/octoherd-hello.js
    at file:///Users/stefanb/code/octoherd-cli/bin/commands/run.js:93:23

If script can not be found

Before

Error: [octoherd] /Users/stefanb/playground/octoherd-hello.js does not exist or is not an ES Module
    at file:///Users/stefanb/code/octoherd-cli/bin/commands/run.js:87:17

After

Error: [octoherd] /Users/stefanb/playground/octoherd-hello.js does not exist
    at file:///Users/stefanb/code/octoherd-cli/bin/commands/run.js:88:19

}

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.

Copy link
Member

@oscard0m oscard0m left a comment

Choose a reason for hiding this comment

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

LGTM but adding @gr2m as reviewer

@oscard0m oscard0m requested a review from gr2m April 7, 2022 12:05
Copy link
Member

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

Sorry for the late review. Our baby boy was born 4 weeks early and he keeps us on our toes :)

@gr2m gr2m merged commit c7742a7 into octoherd:main Apr 20, 2022
@github-actions
Copy link

🎉 This PR is included in version 3.4.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants