Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Implemented a new constructor for Error: from_err() #126

Merged
merged 5 commits into from
Feb 22, 2017

Conversation

golddranks
Copy link
Contributor

from_err() chains another error as the cause of Error.

Another thing to consider is that currently the Error::from_kind() and Error::form_err() constructors take the kind directly. Since this is a ergonomics-oriented library, it might be reasonable to take Into<ErrorKind>? What do you think? Or will it cause inference problems again?

@Yamakaky
Copy link
Contributor

Seems good. Could you add tests?

@golddranks
Copy link
Contributor Author

Yes, but I don't have time and energy to do it now. If you want to, go ahead. If you don't, I'll see what I can do in the following days.

@golddranks
Copy link
Contributor Author

Ok, here's a test.

@Yamakaky
Copy link
Contributor

Seems good. One cosmetic change though: what about from_chain or with_chain instead? from_err can be confused with From<Error>.

@golddranks
Copy link
Contributor Author

Ah, indeed. with_chain seem to be in line with some other ecosystem names. I'll change it to that.

Another thing: What do you think of taking Into<ErrorKind> instead of ErrorKind?

@Yamakaky
Copy link
Contributor

That would be better.

@golddranks
Copy link
Contributor Author

golddranks commented Feb 15, 2017

All right, made the changes.

@Yamakaky
Copy link
Contributor

Yamakaky commented Feb 15, 2017

Sorry, I forgot: could you also update the changelog and add an example in the doc?

@golddranks
Copy link
Contributor Author

I'll do that tomorrow.

@golddranks
Copy link
Contributor Author

Sorry for the delay. I'll do the things starting now.

@golddranks
Copy link
Contributor Author

The other constructor on Error, from_kind doesn't have examples either. Besides, I'm unsure if you meant adding them to the ChainedError trait or for the generated example. Or on the main page. What kind of example were you thinking of?

@Yamakaky
Copy link
Contributor

Yeah, seems good.
Before merge, could you put the trait constraints into the where condition? These lines are way too long ^^

@golddranks
Copy link
Contributor Author

Done!

@Yamakaky Yamakaky merged commit c1341ea into rust-lang-deprecated:master Feb 22, 2017
@Yamakaky
Copy link
Contributor

Thanks a lot!

kw217 added a commit to kw217/error-chain that referenced this pull request Apr 20, 2017
Yamakaky pushed a commit that referenced this pull request Apr 20, 2017
* Clarify usage for chaining and linking.

* Add section on linked errors, and fix references.

* Document with_chain as introduced by #126.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants