Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upError-chain -> failure #202
Conversation
This comment has been minimized.
This comment has been minimized.
|
@steveklabnik curious is there a reason to move towards that over error-chain? |
euclio
reviewed
Oct 25, 2017
| @@ -172,9 +181,9 @@ pub fn build(config: &Config, artifacts: &[&str]) -> Result<()> { | |||
| .stderr(Stdio::piped()) | |||
| .spawn() | |||
| .map_err(|e| if e.kind() == io::ErrorKind::NotFound { | |||
| Error::with_chain(e, format!("frontend `{}` not found", frontend)) | |||
| format_err!("frontend `{}` not found", frontend).into() | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
euclio
Oct 27, 2017
•
Contributor
Looks like it's been renamed to context? It looks like it works slightly differently than chain_err did in error_chain? Hard to say without trying it
This comment has been minimized.
This comment has been minimized.
withoutboats
Oct 28, 2017
Yea I renamed it to context. You could do e.context(format!(...)).into() here.
euclio
reviewed
Oct 25, 2017
| @@ -196,8 +205,8 @@ pub fn build(config: &Config, artifacts: &[&str]) -> Result<()> { | |||
|
|
|||
| /// Run all documentation tests. | |||
| pub fn test(config: &Config) -> Result<()> { | |||
| let doc_json = File::open(config.documentation_path()).chain_err( | |||
| || "could not find generated documentation", | |||
| let doc_json = File::open(config.documentation_path()).map_err(|_| | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This looks interesting! |
This comment has been minimized.
This comment has been minimized.
It's speculated that this kind of library may be preferable to error-chain overall; I wanted to give it a shot to see what the diff looks like. I think I personally prefer it, but the only way to find out is to give it a try. |
This comment has been minimized.
This comment has been minimized.
|
Awesome! |
This comment has been minimized.
This comment has been minimized.
|
@withoutboats while working on the test part of this PR,
Do you have to do something specific to use |
steveklabnik
force-pushed the
failure
branch
from
726d4d0
to
eb88151
Nov 2, 2017
This comment has been minimized.
This comment has been minimized.
withoutboats
commented
Nov 2, 2017
|
|
This comment has been minimized.
This comment has been minimized.
|
Thanks boats! Now our test is failing because of the way we test the context; I suspect that I have to update the macro in some way. More work needed. |
This comment has been minimized.
This comment has been minimized.
|
In this case, it might just be better to check that the cause is the expected type and always return an |
steveklabnik
force-pushed the
failure
branch
2 times, most recently
from
ea4870c
to
5bace42
Nov 22, 2017
This comment has been minimized.
This comment has been minimized.
|
I've rebased this, and it compiles, but has test failures about not being able to find the source test crates. Hrm. |
This comment has been minimized.
This comment has been minimized.
|
Ohh interesting! https://travis-ci.org/steveklabnik/rustdoc/jobs/305812561 even though #203 passed, it's now failing. So it's likely that PR, not this one.... @euclio any ideas? |
This comment has been minimized.
This comment has been minimized.
|
Failing on master too. Probably related to a change in how the analysis is generated. I did a quick test and it should be fixable by updating |
This comment has been minimized.
This comment has been minimized.
|
ah, that makes perfect sense. ill dig in. |
steveklabnik
force-pushed the
failure
branch
from
5bace42
to
9dadf6c
Nov 22, 2017
This comment has been minimized.
This comment has been minimized.
|
Updated and rebased, still failing. I must have missed something somewhere... |
This comment has been minimized.
This comment has been minimized.
|
oh wait looks like a bad rebase.... |
steveklabnik
force-pushed the
failure
branch
from
9dadf6c
to
0e72672
Nov 22, 2017
This comment has been minimized.
This comment has been minimized.
|
Got master passing, this seems to reintroduce it. Hmmmmmmmmm |
steveklabnik
force-pushed the
failure
branch
from
0e72672
to
6936fef
Nov 22, 2017
steveklabnik
force-pushed the
failure
branch
from
6936fef
to
06ed65c
Nov 22, 2017
This comment has been minimized.
This comment has been minimized.
|
@mgattozzi @euclio okay I think this is ready for a review, maybe you'll spot where I messed up. @withoutboats if you have a second as well, that'd be nice. |
euclio
reviewed
Nov 22, 2017
|
|
||
| Directive::Has(regex) | ||
| } | ||
| "matches" => { | ||
| ensure!(args.len() == 2, "not enough arguments"); | ||
| if args.len() == 2 { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
euclio
reviewed
Nov 22, 2017
|
|
||
| Directive::Matches(value) | ||
| } | ||
| "assert" => { | ||
| ensure!(args.len() == 1, "expected 1 argument"); | ||
| if args.len() == 1 { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Awesome, thank you! Of course I messed that up... that leads to just one failure now. |
euclio
reviewed
Nov 22, 2017
| @@ -391,7 +413,7 @@ fn parse_test(line: &str) -> Option<Result<TestCase>> { | |||
| if let Some(caps) = DIRECTIVE_RE.captures(line) { | |||
| let directive = &caps["directive"]; | |||
| let result = parse_directive(directive, &caps["args"], caps.name("negated").is_some()) | |||
| .chain_err(|| ErrorKind::InvalidDirective(line.into())); | |||
| .map_err(|e| e.context(InvalidDirective { d: line.into() }).into()); | |||
This comment has been minimized.
This comment has been minimized.
euclio
Nov 22, 2017
Contributor
I think the context is backwards here. I think that parse_test should return Option<Result<TestCase, InvalidDirective>>. Make sure to set the context of the InvalidDirective error to be the original error. The tests should then check that err.cause() is the expected type.
This comment has been minimized.
This comment has been minimized.
steveklabnik
Nov 22, 2017
Author
Owner
yeah, this is sorta what i'm thinking as well. been toying with this...
euclio
reviewed
Nov 22, 2017
| @@ -401,37 +423,49 @@ fn parse_test(line: &str) -> Option<Result<TestCase>> { | |||
| fn parse_directive(directive: &str, args: &str, negated: bool) -> Result<TestCase> { | |||
| let args = match shlex::split(args) { | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Looks good with comments addressed. Any reason you're preferring |
This comment has been minimized.
This comment has been minimized.
no reason; I'll run clippy too. now dealing with this fun error:
hmmmmmmmmmmmmmmmmm |
This comment has been minimized.
This comment has been minimized.
|
Yeah, I was confused by that too. Does downcasting the cause to |
This comment has been minimized.
This comment has been minimized.
It doesn't seem to, no matter what I try to cast it to, it doesn't seem to do the right thing. Hrm. |
This comment has been minimized.
This comment has been minimized.
|
@euclio so check out this last commit: if we do make it always return |
This comment has been minimized.
This comment has been minimized.
|
Exactly. Error/ErrorKind could work, but since this is an internal-only error that complexity might not be warranted. We could just make it an enum like here. |
steveklabnik
merged commit 7a62956
into
master
Nov 27, 2017
This comment has been minimized.
This comment has been minimized.
|
Time to |
steveklabnik commentedOct 25, 2017
This PR ports us from error-chain to @withoutboats'
failurecrate.I'm done for the day so there's probably CI failures and such, but I wanted to toss this up there so that everyone can see.
/cc @aturon @alexcrichton