@@ -22,12 +22,12 @@ internal class FunctionMetadataGenerator
2222 private readonly IDictionary < string , string > _extensions ;
2323
2424 public FunctionMetadataGenerator ( )
25- : this ( ( l , m ) => { } )
25+ : this ( ( l , m , p ) => { } )
2626 {
2727 _extensions = new Dictionary < string , string > ( ) ;
2828 }
2929
30- public FunctionMetadataGenerator ( Action < TraceLevel , string > log )
30+ public FunctionMetadataGenerator ( Action < TraceLevel , string , string > log )
3131 {
3232 _logger = new IndentableLogger ( log ) ;
3333 _extensions = new Dictionary < string , string > ( ) ;
@@ -81,12 +81,12 @@ public IEnumerable<SdkFunctionMetadata> GenerateFunctionMetadata(string assembly
8181 }
8282 catch ( FunctionsMetadataGenerationException ex )
8383 {
84- _logger . LogError ( $ "Failed to generate function metadata from { Path . GetFileName ( path ) } ." ) ;
84+ _logger . LogError ( $ "Failed to generate function metadata from { Path . GetFileName ( path ) } : { ex . Message } " , path ) ;
8585 throw ex ;
8686 }
8787 catch ( Exception ex )
8888 {
89- _logger . LogWarning ( $ "Could not evaluate '{ Path . GetFileName ( path ) } ' for functions metadata. Exception message: { ex . ToString ( ) } ") ;
89+ _logger . LogWarning ( $ "Could not evaluate '{ Path . GetFileName ( path ) } ' for functions metadata. Exception message: { ex } ") ;
9090 }
9191 }
9292 }
@@ -130,14 +130,23 @@ private void AddFunctionMetadataIfFunction(IList<SdkFunctionMetadata> functions,
130130 if ( TryCreateFunctionMetadata ( method , out SdkFunctionMetadata ? metadata )
131131 && metadata != null )
132132 {
133- var allBindings = CreateBindingMetadataAndAddExtensions ( method ) ;
133+ try
134+ {
135+
136+ var allBindings = CreateBindingMetadataAndAddExtensions ( method ) ;
137+
138+
139+ foreach ( var binding in allBindings )
140+ {
141+ metadata . Bindings . Add ( binding ) ;
142+ }
134143
135- foreach ( var binding in allBindings )
144+ functions . Add ( metadata ) ;
145+ }
146+ catch ( FunctionsMetadataGenerationException ex )
136147 {
137- metadata . Bindings . Add ( binding ) ;
148+ throw new FunctionsMetadataGenerationException ( $ "Failed to generate medata for function ' { metadata . Name } ' (method ' { method . FullName } '): { ex . Message } " ) ;
138149 }
139-
140- functions . Add ( metadata ) ;
141150 }
142151 }
143152
@@ -217,7 +226,7 @@ private void AddOutputBindingsFromReturnType(IList<ExpandoObject> bindingMetadat
217226 else
218227 {
219228 TypeDefinition returnDefinition = returnType . Resolve ( )
220- ?? throw new FunctionsMetadataGenerationException ( $ "Couldn't find the type definition { returnType } ") ;
229+ ?? throw new FunctionsMetadataGenerationException ( $ "Couldn't find the type definition ' { returnType } ' for method ' { method . FullName } ' ") ;
221230
222231 bool hasOutputModel = TryAddOutputBindingsFromProperties ( bindingMetadata , returnDefinition ) ;
223232
0 commit comments