rust-lang-deprecated / error-chain

Error boilerplate for Rust
Apache License 2.0
729 stars 111 forks source link

Finding the documentation difficult for figuring out the best way to integrate error-chain into an existing project #243

Closed jamesray1 closed 6 years ago

jamesray1 commented 6 years ago

I've read over the documentation a few times now, but I am not sure what is the best way to integrate error_chain with the whole project. I've already used the quickstart example to modify the main executable. The project has one executable but it also serves as a library. However I'm not sure what the best way is to integrate error_chain in each crate. For example if I have an error in a file in a module of a crate, how should I integrate that with error_chain in each crate?

More specifically, this file configures the Rust environment variable. How would I integrate the errors in these files with error-chain? There are also other errors in other files in other crate folders.

jamesray1 commented 6 years ago

https://github.com/rust-lang-nursery/error-chain/blob/48c18a9747bb31b663d990f8971963706a4652d7/examples/quickstart.rs#L69-L71

What about when I want to return something? Without error chain, the result of a function is often not (). Do I use Result and then use Ok(some_type_instance)? It doesn't appear to be that simple, since doing that still causes a panic. I have error-chain = "0.11.0" in cargo.toml,

#[macro_use]
extern crate error_chain;

in lib.rs, pub mod errors; in mod.rs, in error_chain!{} in errors.rs, etc.

jamesray1 commented 6 years ago

Closing for now as I think I'm getting the hang of it. The errors that I was getting were unrelated.