-
Notifications
You must be signed in to change notification settings - Fork 411
Improve error message. #644
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
Improve error message. #644
Conversation
Thanks for taking the initiative on this, @joemphilips! I'd also like to see some improvements around our error API. I opened up issue #576 awhile back to discuss such improvements. Would love to get your input on this. Having feedback from someone actively experimenting with Rust Lightning will be valuable. And, of course, I'd welcome any contributions you'd like to make. Regarding this PR, I agree that the message should provide more details to the user. I'd probably opt for using explicit conditions and |
@jkczyz So far I'm happy with this approach, so I don't have much opinion about how we compose error types. But thanks for letting me know about #576 anyway, I may have something to say in the future.
Thanks, I will continue with that approach. |
9b67db5
to
cd7c94d
Compare
Ready for review. I don't know why Travis CI is failing. I think it has nothing to do with my change. |
aac2c8d
to
f2b53e9
Compare
1b21715
to
11a2d7f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
partial review
I'm a fan of these changes, they would've definitely helped me a debug more quickly in the past
One thing is, I think we prefer every commit to compile and pass tests -- I'm guessing commits prior to f2b53e9c99dda14fbb6e3d820de147ee1e08a9ff
wouldn't pass at the moment?
11a2d7f
to
bc1d1a8
Compare
Addressed @valentinewallace 's review and squashed some commits so that every commits pass tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick feedback turnaround!
Great thanks, could you squash in the last two commits then I'll approve? |
8f89271
to
68b3a4f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. Thanks for going through all these error strings!
@@ -881,7 +881,7 @@ mod tests { | |||
assert_eq!(route.paths[0][0].fee_msat, 200); | |||
assert_eq!(route.paths[0][0].cltv_expiry_delta, (13 << 8) | 1); | |||
assert_eq!(route.paths[0][0].node_features.le_flags(), &vec![0b11]); // it should also override our view of their features | |||
assert_eq!(route.paths[0][0].channel_features.le_flags(), &Vec::new()); // No feature flags will meet the relevant-to-channel conversion | |||
assert_eq!(route.paths[0][0].channel_features.le_flags(), &Vec::<u8>::new()); // No feature flags will meet the relevant-to-channel conversion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these changes needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, my compiler complains that it cannot infer the type. (in every rustc version.). I have absolutely no idea why this happens only in this branch, it works fine in master. But giving an type annotation does not hurt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange. I was able to reproduce this but am unsure what would cause rustc to complain.
9c04b33
to
e79317d
Compare
Addressed @jkczyz 's review and re-split commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this detailed PR!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didnt check every line in the diff, but seems good pending val and Jeff's review.
@@ -28,3 +28,4 @@ features = ["bitcoinconsensus"] | |||
|
|||
[dev-dependencies] | |||
hex = "0.3" | |||
regex = "0.1.80" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not regex 1.3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the latest release version which compiles in rustc 1.22.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh. Hmm, looks like their MSRV is still 1.28 (https://github.com/rust-lang/regex/blob/master/.github/workflows/ci.yml#L34) maybe lets just finally bump the MSRV to that given rust-bitcoin may bump to 1.29 sooner or later anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose bumping the MSRV should be done with other PR so should I rebase after that PR gets merged? I think it is fine to use old regex though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
e79317d
to
6a2ae52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
In the future, it would be less daunting for reviewers if the PR could be broken into more atomic commits. For instance, here one commit to switch from &'static str
to String
and another to update the error messages.
@@ -881,7 +881,7 @@ mod tests { | |||
assert_eq!(route.paths[0][0].fee_msat, 200); | |||
assert_eq!(route.paths[0][0].cltv_expiry_delta, (13 << 8) | 1); | |||
assert_eq!(route.paths[0][0].node_features.le_flags(), &vec![0b11]); // it should also override our view of their features | |||
assert_eq!(route.paths[0][0].channel_features.le_flags(), &Vec::new()); // No feature flags will meet the relevant-to-channel conversion | |||
assert_eq!(route.paths[0][0].channel_features.le_flags(), &Vec::<u8>::new()); // No feature flags will meet the relevant-to-channel conversion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange. I was able to reproduce this but am unsure what would cause rustc to complain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@@ -28,3 +28,4 @@ features = ["bitcoinconsensus"] | |||
|
|||
[dev-dependencies] | |||
hex = "0.3" | |||
regex = "0.1.80" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
... for ChannelError and APIMisuseError Before this commit, When rl returns error, we don't know The actual parameter which caused the error. By returning parameterised `String` instead of predefined `&'static str`, We can give a caller improved error message. TestLogger now has two additional methods 1. `assert_log_contains` which checks the logged messsage has how many entry which includes the specified string as a substring. 2. `aasert_log_regex` mostly the same with `assert_log_contains` but it is more flexible that caller specifies regex which has to be satisfied instead of just a substring. For regex, tests now includes `regex` as dev-dependency.
For making debugging easy. If the user gives a different node_secret for transport layer (`PeerManager`) and for routing msg, internal_announcement_signatures is the first place it causes an error. By giving a detailed error message, user will be able to fix the bug quickly.
6a2ae52
to
407e306
Compare
... for ChannelError and APIMisuseError
Before this commit, When rl returns error, we don't know
The actual parameter which caused the error.
By returning parameterised
String
instead of predefined&'static str
,We can give a caller improved error message.
This will make my life easier when I'm debugging my server by connecting to other lightning nodes.
But I'm not sure if this is a sane approach. So I want to have a concept ACK before continuing my work.
The code does not compile but I suppose it is good enough to show what I'm trying to do to a reviewer.