question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error_chain's Result<T> support

See original GitHub issue

When using the error_chain crate it’s common to define the errors in a “errors.rs” mod and import them where needed with use errors::*.

This overrides the default Result<T,E> enum with a Result<T>, and intellij-rust reports all the functions using it as errors (Wrong number of arguments: expected 2, found 1 [E0243]).

I know it’s hard to parse macros (see #955), but I was wondering if there is a way to use annotations to declare the definition of enums, structs or functions (like // @defines Result<T> or similar) to use in the mod defining them, so that the parser recognizes them.

P.S.: sorry for the empty bug report earlier, I don’t know what I pressed to post it while writing… 😃

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:19
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
matkladcommented, May 19, 2017

Make E0243 an inspection instead of annotation, so it could be opted out.

Yeah, we definitely should do this with perhaps most of the errors: combination of macros and shadowing leads to false positives 😦

Special casing error_chain! would be a nice addition!

2reactions
FauxFauxcommented, Jan 19, 2018

I’ve been using this as a workaround, if anyone else is interested:

https://github.com/FauxFaux/error-chain-for-dumb-ides#error-chain-for-dumb-ides

Read more comments on GitHub >

github_iconTop Results From Across the Web

Crate error_chain - Docs.rs
Introducing new error chains, with a string message: fn foo() -> Result<()> ... error-chain supports extending an error chain by appending new errors....
Read more >
Concatentating error chains · Issue #93 · dtolnay/anyhow
I have a program that has several mechanisms that it can use to accomplish its task; they are attempted in order from most...
Read more >
Crate error_chain - Rust
Introducing new error chains, with a string message: fn foo() -> Result<()> ... error-chain supports extending an error chain by appending new errors....
Read more >
errors package - github.com/signalfx/golib/v2/errors - Go Packages
Note returns error rather than *ErrorChain so that it matches errors. ... PanicIfErrWrite is similar to PanicIfErr, but works well with io results...
Read more >
Sending MDM Commands to a Device - Apple Developer
Execute commands on a device and receive responses that contain the results of each operation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found