-
Notifications
You must be signed in to change notification settings - Fork 2.7k
make helper error types generics #7878
Conversation
45b6ca2 to
9d86ee3
Compare
ordian
left a comment
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.
small nits, but looks good other than that
Co-authored-by: Andronik Ordian <write@reusable.software>
|
Can you outline the details of what we try to achieve here more clearly? On the first glance it doesn't seem very convenient to have the caller define the type - why couldn't the caller simply wrap a concrete Having the return type generic makes pretty confusing API and may sometimes require extra type annotations (i.e. you most likely can't do |
|
Currently in polkadot there is a cli module with additional CLI parameters which re-uses parts of the substrate provided convenience If the error types are generics, the user of the substrate lib has the power to define the wrapping type and avoid (i.e. ) From my pov substrate is a framework, so if there is user code that could potentially return other error types within that closure, we should provide a path / allow those to be propagated instead. It's not about if we use |
tomusdrw
left a comment
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.
@drahnr thanks for explanations! Indeed seems like the right way.
cecton
left a comment
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.
OK I see the point now 🤗
* network-gossip: add metric for number of local messages * grandpa: fix GossipEngine missing metrics registry parameter * network-gossip: increase known messages cache size * network-gossip: fix tests * grandpa: remove unnecessary clone Co-authored-by: Max Inden <mail@max-inden.de> * network-gossip: count registered and expired messages separately * network-gossip: add comment on known messages cache size * network-gossip: extend comment with cache size in memory Co-authored-by: Max Inden <mail@max-inden.de>
* Remove statistics system * Remove ContextData struct * Remove next_request_id * Some TryFrom nit-picking * Use constants for peer sets
…tem (#7879) * Add `len` function that can return the length of a storage item efficiently * Make use of the new len function in contracts * Fix benchmarks * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs * Remove unused imports Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
* Fix clear prefix check to avoid erasing child trie roots. * Renaming and extend existing test with check. * last nitpicks.
Makes a few helper error fn result types generic over the error type.
This helps to simplify using them with custom error types without resorting to
Error -> String -> Errorconversions, which loses the traceability / source errors.polkadot companion: paritytech/polkadot#2254