Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method name is added to exception message. #787

Merged
merged 2 commits into from
May 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions dotnet/src/SemanticKernel/SkillDefinition/SKFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ private static MethodDetails GetMethodDetails(MethodInfo methodSignature, object

if (!result.HasSkFunctionAttribute || skFunctionAttribute == null)
{
log?.LogTrace("Method {0} doesn't have SKFunctionAttribute", result.Name);
log?.LogTrace("Method '{0}' doesn't have '{1}' attribute.", result.Name, typeof(SKFunctionAttribute).Name);
return result;
}

Expand Down Expand Up @@ -554,9 +554,8 @@ private static MethodDetails GetMethodDetails(MethodInfo methodSignature, object
else if (skMainParam != null)
{
// The developer used [SKFunctionInput] on a function that doesn't support a string input
shawncal marked this conversation as resolved.
Show resolved Hide resolved
throw new KernelException(
KernelException.ErrorCodes.InvalidFunctionDescription,
"The function doesn't have a string parameter, do not use " + typeof(SKFunctionInputAttribute));
var message = $"The method '{result.Name}' doesn't have a string parameter, do not use '{typeof(SKFunctionInputAttribute).Name}' attribute.";
throw new KernelException(KernelException.ErrorCodes.InvalidFunctionDescription, message);
}

// Handle named arg passed via the SKContext object
Expand All @@ -570,7 +569,7 @@ private static MethodDetails GetMethodDetails(MethodInfo methodSignature, object

result.Description = skFunctionAttribute.Description ?? "";

log?.LogTrace("Method {0} found", result.Name);
log?.LogTrace("Method '{0}' found.", result.Name);

return result;
}
Expand Down Expand Up @@ -678,13 +677,13 @@ private static (DelegateTypes type, Delegate function, bool hasStringParam) GetD
{
throw new KernelException(
KernelException.ErrorCodes.FunctionTypeNotSupported,
$"Function {method.Name} has an invalid signature 'Func<SKContext, SKContext>'. " +
$"Function '{method.Name}' has an invalid signature 'Func<SKContext, SKContext>'. " +
"Please use 'Func<SKContext, Task<SKContext>>' instead.");
}

throw new KernelException(
KernelException.ErrorCodes.FunctionTypeNotSupported,
$"Function {method.Name} has an invalid signature not supported by the kernel");
$"Function '{method.Name}' has an invalid signature not supported by the kernel.");
}

[SuppressMessage("Maintainability", "CA1508:Avoid dead conditional code", Justification = "Delegate.CreateDelegate result can be null")]
Expand Down