-
Notifications
You must be signed in to change notification settings - Fork 2.7k
construct_runtime macro needs to generate runtime Error type #4040
Comments
Why? Where do we need generic errors? Please provide an example. |
This code https://github.com/laminar-protocol/open-runtime-module-library/blob/master/tokens/src/lib.rs if I add So I would like to add The remaining problem will be construct a type satisfies the type bonds for |
My feeling is that an error is different from an event, if you call let's say staking module and the error received is balance module saying balance too low, you may not be able to know what triggered this error, staking module must put meanings on what has triggered this too low balance. On the other hand an event is meaningfull by itself, however it has been triggered this event happened on chain. |
considering this discussion #4385 (comment) EDIT: but what confused me is that this is very different from what a rust error should be, that is to say a meaning full message from the called function with possibly some wrapped origin. |
If we don't have the limitation of onchain storage, we can totally just use a popular Rust error handling library and good to go. But with the constraints, we just can't retain all the details. What we can do is maybe come out some macro that switch between the lite error code or with full error stack trace based on std feature. But this should happen after we have the lite error code version fully implemented. |
Fixed by #4449 |
It needs to generate runtime Error type similar to how it generate runtime Event type so different module error can all
Into<T::Error>
wheretype Error: From<Error> + From<system::Error> + any_other_used_module::Error
Otherwise
decl_error
is much less usefulFollow up of #2880 #3433
The text was updated successfully, but these errors were encountered: