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

fix: properly handle non error exceptions #694

Merged
merged 15 commits into from
Jan 17, 2023

Conversation

andrewvc
Copy link
Contributor

@andrewvc andrewvc commented Jan 11, 2023

Catch non Error objects that are thrown as exceptions. As a quick workaround devs sometimes throw using syntax like throw("foo") instead of the more correct throw(new Error("foo")).

The current code will swallow those errors.

Fixes #692

Testing

This PR includes a simple unit test. Given that the impact of #692 is low, and writing a true E2E test demonstrating the resolution of that issue, I think manual testing of that scenario is fine.

To do so, save the following file as bad.ts

//bad.ts

step("instant exception", () => {
  throw("simple exception");
})

Then, run

npm run build && node dist/cli.js --inline --rich-events < bad.ts | grep journey/end |  jq .error`

after checking out this branch. You should see this error. Switching back to main the error should be missing.

@andrewvc andrewvc added the bug Something isn't working label Jan 11, 2023
@apmmachine
Copy link

apmmachine commented Jan 11, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-01-17T14:48:34.619+0000

  • Duration: 16 min 33 sec

Test stats 🧪

Test Results
Failed 0
Passed 211
Skipped 2
Total 213

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@andrewvc andrewvc marked this pull request as ready for review January 11, 2023 22:15
src/helpers.ts Outdated Show resolved Hide resolved
@vigneshshanmugam vigneshshanmugam changed the title Properly handle non error exceptions fix: properly handle non error exceptions Jan 17, 2023
Copy link
Member

@vigneshshanmugam vigneshshanmugam left a comment

Choose a reason for hiding this comment

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

LGTM

@andrewvc andrewvc merged commit 1f05734 into elastic:main Jan 17, 2023
@andrewvc andrewvc deleted the catch-all-errors branch January 17, 2023 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Thrown exceptions causes steps to fail, but not the whole journey
3 participants