@@ -90,9 +90,37 @@ pub fn expand_outer_inherent(
9090 use #scrate:: inherent:: { ProvideInherent , IsFatalError } ;
9191 use #scrate:: traits:: { IsSubType , ExtrinsicCall } ;
9292 use #scrate:: sp_runtime:: traits:: Block as _;
93+ use #scrate:: _private:: sp_inherents:: Error ;
94+ use #scrate:: log;
9395
9496 let mut result = #scrate:: inherent:: CheckInherentsResult :: new( ) ;
9597
98+ // This handle assume we abort on the first fatal error.
99+ fn handle_put_error_result( res: Result <( ) , Error >) {
100+ const LOG_TARGET : & str = "runtime::inherent" ;
101+ match res {
102+ Ok ( ( ) ) => ( ) ,
103+ Err ( Error :: InherentDataExists ( id) ) =>
104+ log:: debug!(
105+ target: LOG_TARGET ,
106+ "Some error already reported for inherent {:?}, new non fatal \
107+ error is ignored",
108+ id
109+ ) ,
110+ Err ( Error :: FatalErrorReported ) =>
111+ log:: error!(
112+ target: LOG_TARGET ,
113+ "Fatal error already reported, unexpected considering there is \
114+ only one fatal error",
115+ ) ,
116+ Err ( _) =>
117+ log:: error!(
118+ target: LOG_TARGET ,
119+ "Unexpected error from `put_error` operation" ,
120+ ) ,
121+ }
122+ }
123+
96124 for xt in block. extrinsics( ) {
97125 // Inherents are before any other extrinsics.
98126 // And signed extrinsics are not inherents.
@@ -110,9 +138,9 @@ pub fn expand_outer_inherent(
110138 if #pallet_names:: is_inherent( call) {
111139 is_inherent = true ;
112140 if let Err ( e) = #pallet_names:: check_inherent( call, self ) {
113- result. put_error(
141+ handle_put_error_result ( result. put_error(
114142 #pallet_names:: INHERENT_IDENTIFIER , & e
115- ) . expect ( "There is only one fatal error; qed" ) ;
143+ ) ) ;
116144 if e. is_fatal_error( ) {
117145 return result;
118146 }
@@ -153,19 +181,19 @@ pub fn expand_outer_inherent(
153181 } ) ;
154182
155183 if !found {
156- result. put_error(
184+ handle_put_error_result ( result. put_error(
157185 #pallet_names:: INHERENT_IDENTIFIER , & e
158- ) . expect ( "There is only one fatal error; qed" ) ;
186+ ) ) ;
159187 if e. is_fatal_error( ) {
160188 return result;
161189 }
162190 }
163191 } ,
164192 Ok ( None ) => ( ) ,
165193 Err ( e) => {
166- result. put_error(
194+ handle_put_error_result ( result. put_error(
167195 #pallet_names:: INHERENT_IDENTIFIER , & e
168- ) . expect ( "There is only one fatal error; qed" ) ;
196+ ) ) ;
169197 if e. is_fatal_error( ) {
170198 return result;
171199 }
0 commit comments