expose module errors into metadata (#3752)

* expose module errors into metadata

* it checks

* Tests for error metadata

* Apply suggestions from code review

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* remove inherent errors from metadata

* bump version

* Apply suggestions from code review

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update srml/support/src/error.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Xiliang Chen
2019-10-08 22:30:16 +13:00
committed by Bastian Köcher
parent 38a61861b1
commit 2c77262c8f
5 changed files with 94 additions and 12 deletions
+9 -1
View File
@@ -23,7 +23,7 @@ pub use std::fmt;
pub use crate::codec::{Codec, EncodeLike, Decode, Encode, Input, Output, HasCompact, EncodeAsRef};
pub use srml_metadata::{
FunctionMetadata, DecodeDifferent, DecodeDifferentArray, FunctionArgumentMetadata,
ModuleConstantMetadata, DefaultByte, DefaultByteGetter,
ModuleConstantMetadata, DefaultByte, DefaultByteGetter, ModuleErrorMetadata, ErrorMetadata
};
pub use sr_primitives::{
weights::{
@@ -1298,6 +1298,14 @@ macro_rules! decl_module {
{ $( $other_where_bounds )* }
$( $constants )*
}
impl<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $crate::dispatch::ModuleErrorMetadata
for $mod_type<$trait_instance $(, $instance)?> where $( $other_where_bounds )*
{
fn metadata() -> &'static [$crate::dispatch::ErrorMetadata] {
<$error_type as $crate::dispatch::ModuleErrorMetadata>::metadata()
}
}
}
}