[WIP/do not merge] Replace anyhow with typed errors in wit-parser#2460
Draft
PhoebeSzmucer wants to merge 2 commits intobytecodealliance:mainfrom
Draft
[WIP/do not merge] Replace anyhow with typed errors in wit-parser#2460PhoebeSzmucer wants to merge 2 commits intobytecodealliance:mainfrom
anyhow with typed errors in wit-parser#2460PhoebeSzmucer wants to merge 2 commits intobytecodealliance:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Today, getting a file path and line number out of a parse error requires parsing the human-readable error string that anyhow produces. This is fragile: it breaks silently when error message formatting changes, and it's simply the wrong abstraction.
I want to use
wit-parserin an LSP for WIT/WAC, but this change would be good for any tool that embedswit-parserand wants to do something useful with errors.I Know This Is Large
I'm aware this PR is bigger than ideal. The core reason it's large is that error type changes propagate through the entire call stack - there's no natural seam to split at. If this is something that we'd like to merge in some form, I can try splitting up this PR into smaller chunks - I wanted to open this draft first to start a conversation.
Global vs local spans
Currently I'm returning global
Spanobjects as part ofWitError, because existing code uses global spans almost exclusively. This makes things annoying for the consumer - they have to use theSourceMapobject to map to file-local offsets. I'm considering changing the exposed spans to be resolved local spans.