@@ -231,20 +231,29 @@ List<MethodBase> GetBulkMethods()
231231 return list ;
232232 }
233233
234- static string FailOnResult ( IEnumerable < MethodBase > res )
234+ var result = new List < MethodBase > ( ) ;
235+
236+ var targetMethods = RunMethod < HarmonyTargetMethods , IEnumerable < MethodBase > > ( null , null ) ;
237+ if ( targetMethods is object )
235238 {
236- if ( res is null ) return "null" ;
237- if ( res . Any ( m => m is null ) ) return "some element was null" ;
238- return null ;
239+ string error = null ;
240+ result = targetMethods . ToList ( ) ;
241+ if ( result is null ) error = "null" ;
242+ else if ( result . Any ( m => m is null ) ) error = "some element was null" ;
243+ if ( error != null )
244+ {
245+ if ( auxilaryMethods . TryGetValue ( typeof ( HarmonyTargetMethods ) , out var method ) )
246+ throw new Exception ( $ "Method { method . FullDescription ( ) } returned an unexpected result: { error } ") ;
247+ else
248+ throw new Exception ( $ "Some method returned an unexpected result: { error } ") ;
249+ }
250+ return result ;
239251 }
240- var targetMethods = RunMethod < HarmonyTargetMethods , IEnumerable < MethodBase > > ( null , null , FailOnResult ) ;
241- if ( targetMethods is object )
242- return targetMethods . ToList ( ) ;
243252
244- var result = new List < MethodBase > ( ) ;
245253 var targetMethod = RunMethod < HarmonyTargetMethod , MethodBase > ( null , null , method => method is null ? "null" : null ) ;
246254 if ( targetMethod is object )
247255 result . Add ( targetMethod ) ;
256+
248257 return result ;
249258 }
250259
0 commit comments