-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Expose manifest error chain in CargoErrors #6157
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @matklad (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Thanks for the PR! I wonder though if the filtering of "don't wrap I/O errors" can happen in a different location? Ideally we'd deterministically wrap an error in a manifest error after a certain point instead of filtering after-the-fact (which seems like it could be lossy) |
Yes i think that probably can be removed, it'll mean finding the correct manifest to plonk the error on will be a little harder. But it also makes it simpler. |
Looks like some tests are failing, but is this also the best place perhaps? I would have expected error wrapping like this to happen somewhere within |
Simply wrapping in However, the initial manifest error could come from there. I'll see if that works. |
Thanks! I'm not really sure what the |
Well these errors provide a chain of info to lib users, they don't add any "displayable" info for the message / bin users. Because of this I thought it made sense to filter them out of the text output, plus having them in caused a bunch of tests to fail as some error messages became duplicated. I added the trait to make the meaning clearer, rather than filtering |
I think we have at least one or two instances of "marker errors" in Cargo, and I think those strategies could be used to avoid duplication of error messages? I think the |
The difference here though is that I'm intending to change the backtrace. The backtrace is added to in order to trace the manifests involved in an error. |
Yes it should be possible to have type-level markers in the backtrace which don't affect how it's printed (without the addition of a new method). I believe that's how internal errors work in Cargo today (although they're specifically used to change printing, but only because it's special cased) |
The wrapped error indeed doesn't affect the display. The filtering is used when we're printing each cause in the chain.
becomes
When printing out the displays this isn't useful, hence the filtering. Yet I do want this "duplication", because each extra link has extra info. In particular which manifest inside a project is "nearest" to the error. I guess I'm doing a bad job at explaining this. I feel like I'm dancing around the same points and probably missing what you're after. |
@alexheretic er sorry well my point is that I would recommend looking at |
As I'm currently using the cause-chain to get the manifests involved I don't think Perhaps I could provide a different chain of |
Filter out ManifestErrors when generating error output
3549788
to
25b7ad2
Compare
Ok maybe this is what you're after, now lower impact outside of the intended usage as a new method |
@bors: r+ Ah yeah that looks good to me, thanks so much! |
📌 Commit 25b7ad2 has been approved by |
⌛ Testing commit 25b7ad2 with merge 04c689ebf17be091e7a173034422e4fee5a0a208... |
💔 Test failed - status-appveyor |
@bors: retry |
Expose manifest error chain in CargoErrors Adds new `ManifestError`s to the `CargoError` causal chain. These errors pass on their display, but provide more detail on which manifests are at fault when failing to build a `Workspace`. This is useful for lib users, in particular rls, allowing lookup of a particular manifest file that caused the error. See #6144. For example a workspace _foo_ where a member _bar_ has an invalid toml manifest would have the error chain: - failed to parse manifest at `/home/alex/project/foo/bar/Cargo.toml` _ManifestError: /home/alex/project/foo/Cargo.toml_ - failed to parse manifest at `/home/alex/project/foo/bar/Cargo.toml` _ManifestError: /home/alex/project/foo/bar/Cargo.toml_ - failed to parse manifest at `/home/alex/project/foo/bar/Cargo.toml` - could not parse input as TOML - expected a value, found an equals at line 8 This will allow rls to point to a particular workspace member's manifest file when that manifest fails to deserialize, has invalid paths, etc. This change should not affect binary use.
@alexcrichton thanks for patiently reviewing this! |
☀️ Test successful - status-appveyor, status-travis |
Add PackageError wrappers for activation errors Similarly to #6157 this wraps compile errors with `PackageId` info to allow lib users, in this case rls, to discern where something went wrong. In particular if a dependency has a dodgy version or doesn't exist the error chain will now contain a <s>PackageError that provides the package id</s> `ResolveError` that provides the package path from error-parent -> root. From this I figure out if the error better relates to a workspace member, and target that manifest for diagnostics.
Add PackageError wrappers for activation errors Similarly to #6157 this wraps compile errors with `PackageId` info to allow lib users, in this case rls, to discern where something went wrong. In particular if a dependency has a dodgy version or doesn't exist the error chain will now contain a <s>PackageError that provides the package id</s> `ResolveError` that provides the package path from error-parent -> root. From this I figure out if the error better relates to a workspace member, and target that manifest for diagnostics.
Adds new
ManifestError
s to theCargoError
causal chain. These errors pass on their display, but provide more detail on which manifests are at fault when failing to build aWorkspace
. This is useful for lib users, in particular rls, allowing lookup of a particular manifest file that caused the error. See #6144.For example a workspace foo where a member bar has an invalid toml manifest would have the error chain:
/home/alex/project/foo/bar/Cargo.toml
ManifestError: /home/alex/project/foo/Cargo.toml
/home/alex/project/foo/bar/Cargo.toml
ManifestError: /home/alex/project/foo/bar/Cargo.toml
/home/alex/project/foo/bar/Cargo.toml
This will allow rls to point to a particular workspace member's manifest file when that manifest fails to deserialize, has invalid paths, etc.
This change should not affect binary use.