-
Notifications
You must be signed in to change notification settings - Fork 12
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
Use failure for error handling #20
Conversation
* Add dependency on failure crate * Use String instead of &'a str in ParseError and LicenseExpr * Eliminate use of error_chain, use failure::Error instead
I don't know enough Rust to evaluate this. Is |
@wking I'd say a bit of both. The entire ecosystem is encouraged to move toward See the original announcement by @withoutboats and the nursery repo for more details. Also, please take a look at rust-lang-deprecated/failure#181. |
Just a note: this would be a breaking change. Seeing as the cargo registry is the only public crate that currently depends on this I don't think releasing a new minor version would be too bad though. |
Actually, I'm highly against changing the interface to clone the substrings, there's no reason the parsed license expression can't borrow back into the input string. EDIT: Especially when the only public API doesn't even give you access to the parsed expression currently, so you're wasting all this work cloning the substrings then just discarding them. |
Part of the problem with returning substrings with lifetimes in the error types is that I cannot easily use them with other projects that implement |
The |
That sounds like an excellent solution! It doesn't lock the crate to using |
I'm going to be trying to replace the current parser with one that allows getting access to the actual parsed expression this week, I'll definitely keep using |
Sure! It sounds like important work is being done; that's terrific. If it should likely be completed sometime this week, then I'd be happy to wait. We can close this PR once the other one gets merged. Thanks for the heads up. |
Doing some cleanup; it looks like this change is stale and not what's ultimately desired anyway, so I'm closing this PR. Thank you! |
@carols10cents Thanks for the cleanup! I hope that the parser and error handling improvements are incorporated sometime so this crate can be more useful to the public at large. |
Added
failure
crate.Changed
String
instead of&'a str
inParseError
andLicenseExpr
to satisfy'static
bound onFail
trait.error_chain
infetch-license-from-spdx
example; usefailure::Error
instead.rustfmt
on codebase.