-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Improve error handling in approval voting block import #5283
Improve error handling in approval voting block import #5283
Conversation
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.
Nice.
Just noticed I was not asked to review.
RuntimeError(RuntimeApiError), | ||
|
||
#[error("future cancalled while requesting {0}")] | ||
FutureCancelled(&'static str, futures::channel::oneshot::Canceled), |
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.
Canceled
should be annotated with #[source]
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.
Ah, I missed that.
That said, in this case in practice since Canceled
is a ZST and doesn't actually carry any information it shouldn't make any practical difference.
I'm happy to make a followup PR and add this in 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.
Just a nit :)
/// The runtime API cannot be executed due to a | ||
#[error("The runtime API '{runtime_api_name}' cannot be executed")] | ||
/// The runtime API cannot be executed due to a runtime error. | ||
#[error("The runtime API '{runtime_api_name}' cannot be executed: {source}")] |
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.
nit: source
will be printed twice now in the backtrace, once as part of the backtrace and as part of the error message itself iirc
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.
Do you know how you'd have to print it out to actually get it printed out twice?
Because when printed out through a normal Display
trait:
#[test]
fn test_foobar() {
#[derive(thiserror::Error, Debug)]
#[error("source")]
struct Source;
let err = RuntimeApiError::Execution { runtime_api_name: "Test", source: Arc::new(Source) };
panic!("{}", err);
}
it's printed out like this:
thread 'import::tests::test_foobar' panicked at 'The runtime API 'Test' cannot be executed: source', node/core/approval-voting/src/import.rs:1351:9
And we usually print out errors through Display
(or Debug
).
There are two ways to get the full error chain:
or using a predfined formatter, i.e.
which also shows the backtrace if captured :) |
Okay, I see! I was asking because I've never seen this in our codebase, and a quick grep confirms that neither the So in theory you're right, but yeah, it practice it doesn't seem to matter; at this point this train has already left the station a long time ago, and it'd take a huge effort to rework the whole codebase to use any other way of printing out errors. We can't even guarantee that we use |
We do, every error that bubbles up to the main fn will be printed using
Using a helper |
* master: (62 commits) Bump tracing from 0.1.32 to 0.1.33 (#5299) Add staging runtime api (#5048) CI: rename ambiguous jobs (#5313) Prepare for rust 1.60 (#5282) Bump proc-macro2 from 1.0.36 to 1.0.37 (#5265) Fixes the dead lock when any of the channels get at capacity. (#5297) Bump syn from 1.0.90 to 1.0.91 (#5273) create .github/workflows/pr-custom-review.yml (#5280) [ci] fix pallet benchmark script (#5247) (#5292) bump spec_version to 9190 (#5291) bump version to 0.9.19 (#5290) Session is actually ancient not unknown. (#5286) [ci] point benchmark script to sub-commands (#5247) (#5289) Remove Travis CI (#5287) Improve error handling in approval voting block import (#5283) fix .github/pr-custom-review.yml (#5279) Co #11164: Sub-commands for `benchmark` (#5247) Bump clap from 3.1.6 to 3.1.8 (#5240) Custom Slots Migration for Fund Index Change (#5227) create pr-custom-review.yml (#5253) ...
We already print out a warning here, so we might as well also print out the actual error message instead of just ignoring it.
(Motivation: I was investigating this issue which triggers this warning. I'd like to have the WASM stack trace printed out in the error message when something panics; we can't do that if the errors are ignored and never printed out the first place.)