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

Visitor: allow short-circuiting on error #406

Merged
merged 3 commits into from
Feb 9, 2023
Merged

Visitor: allow short-circuiting on error #406

merged 3 commits into from
Feb 9, 2023

Conversation

georgeclaghorn
Copy link
Contributor

@georgeclaghorn georgeclaghorn commented Jan 23, 2023

In Classmate, visitors call fallible Ruby methods. I’d like to stop traversal at the first error and propagate it back up to the caller.

I currently approximate that by storing the error on the visitor and wrapping each Visitor method’s body in if self.error.is_none() { ... }. It would be nicer if I could just return an error from a visitor method and let it bubble up. This PR makes that possible.

The JS bindings’ JsVisitor intentionally remains infallible to preserve existing behavior, where it continues traversal after an error, but it could adopt the new behavior if desired.

@devongovett
Copy link
Member

Thanks this looks like a good feature. Will look more in depth soon!

@devongovett devongovett merged commit 72bf818 into parcel-bundler:master Feb 9, 2023
@georgeclaghorn georgeclaghorn deleted the visitor-error branch February 9, 2023 16:11
@devongovett
Copy link
Member

Thanks again and sorry for the delay in looking at this. I also updated the JS transformer to use the fallible visitor functions as well: 366d923.

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

Successfully merging this pull request may close these issues.

None yet

2 participants