-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat: Use a typed error to allow getting location without parsing #43
Conversation
Maybe! What is your goal? What data do you want to access on errors? |
My goal is generally processing errors using the error handler of the project - the one of swc for I think an |
What kind of error? Sorry, I don’t understand. |
I meant parsing error vs transform error vs etc but maybe those can be merged |
I’m not sure what a parsing error vs a transforming error is. Most errors are parsing errors, 90% vs. 10% probably? Do users care about what is a parse or transform error? Some more background: In my comments in the related issue, I proposed matching what we do in JavaScript. The algorithms are very similar. Compare what happens in Rust: With what happens in JavaScript: https://github.com/micromark/micromark-extension-mdx-jsx/blob/main/dev/lib/factory-tag.js#L181-L188 I think it’s good to keep the code bases similar for maintainers, and also to keep errors similar for users. Like JavaScript, we can also use a struct with different fields. Q: in your OP you said “To avoid modifying markdown-rs”. Why? Why not create an error struct there, that can also be used here? |
I think behaving similarly is a good idea.
It was about using
|
I'm not sure if the user actually cares about error kinds. Maybe it's enough if we don't need to parse the error message. |
Where are you parsing errors? |
I don't (yet), but I want to show good errors to users. |
@wooorm Is this what you meant by an error struct? |
I updated the PR description |
Closes GH-108. Closes GH-114. Closes: wooorm/mdxjs-rs#42. Closes: wooorm/mdxjs-rs#43.
I added an error type, which consists of the error message and optional source location.
This would be enough for most users, including usage in next.js/turbopack - providing good error message with some underline to the source code.