mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
Exception classes in the API should extend SKException (#1112)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows SK Contribution Guidelines (https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) - [ ] The code follows the .NET coding conventions (https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions) verified with `dotnet format` - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** Kernel logic exception */
|
||||
public class KernelException extends RuntimeException {
|
||||
public class KernelException extends SKException {
|
||||
|
||||
@Nonnull private final ErrorCodes errorCode;
|
||||
|
||||
|
||||
+31
-1
@@ -1,4 +1,34 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
package com.microsoft.semantickernel;
|
||||
|
||||
public class SKException extends RuntimeException {}
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** Provides the base exception from which all Semantic Kernel exceptions derive. */
|
||||
public class SKException extends RuntimeException {
|
||||
|
||||
/** Initializes a new instance of the {@code SKException} class with a default message. */
|
||||
protected SKException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the {@code SKException} class with its message set to {@code
|
||||
* message}.
|
||||
*
|
||||
* @param message A string that describes the error.
|
||||
*/
|
||||
protected SKException(@Nullable String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the {@code SKException} class with its message set to {@code
|
||||
* message}.
|
||||
*
|
||||
* @param message A string that describes the error.
|
||||
* @param cause The exception that is the cause of the current exception.
|
||||
*/
|
||||
protected SKException(@Nullable String message, @Nullable Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,11 +1,13 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
package com.microsoft.semantickernel.ai; // Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
import com.microsoft.semantickernel.SKException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** AI logic exception */
|
||||
public class AIException extends RuntimeException {
|
||||
public class AIException extends SKException {
|
||||
|
||||
@Nonnull private final ErrorCodes errorCode;
|
||||
|
||||
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
package com.microsoft.semantickernel.diagnostics;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** Provides the base exception from which all Semantic Kernel exceptions derive. */
|
||||
public class SKException extends RuntimeException {
|
||||
|
||||
/** Initializes a new instance of the {@code SKException} class with a default message. */
|
||||
protected SKException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the {@code SKException} class with its message set to {@code
|
||||
* message}.
|
||||
*
|
||||
* @param message A string that describes the error.
|
||||
*/
|
||||
protected SKException(@Nullable String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the {@code SKException} class with its message set to {@code
|
||||
* message}.
|
||||
*
|
||||
* @param message A string that describes the error.
|
||||
* @param cause The exception that is the cause of the current exception.
|
||||
*/
|
||||
protected SKException(@Nullable String message, @Nullable Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,7 +1,9 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
package com.microsoft.semantickernel.exceptions;
|
||||
|
||||
public class NotSupportedException extends RuntimeException {
|
||||
import com.microsoft.semantickernel.SKException;
|
||||
|
||||
public class NotSupportedException extends SKException {
|
||||
public NotSupportedException(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
package com.microsoft.semantickernel.exceptions;
|
||||
|
||||
public class SkillsNotFoundException extends RuntimeException {}
|
||||
import com.microsoft.semantickernel.SKException;
|
||||
|
||||
public class SkillsNotFoundException extends SKException {}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
package com.microsoft.semantickernel.memory;
|
||||
|
||||
import com.microsoft.semantickernel.diagnostics.SKException;
|
||||
import com.microsoft.semantickernel.SKException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+10
-8
@@ -1,15 +1,17 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
package com.microsoft.semantickernel.orchestration;
|
||||
|
||||
public class FunctionNotRegisteredException extends RuntimeException {
|
||||
import com.microsoft.semantickernel.SKException;
|
||||
|
||||
public class FunctionNotRegisteredException extends SKException {
|
||||
|
||||
private static final String format =
|
||||
"It does not appear this function(%s) has been registered on a kernel.%n"
|
||||
+ "Register it on a kernel either by passing it to "
|
||||
+ "KernelConfig.Builder().addSkill() when building the kernel, or%n"
|
||||
+ "passing it to Kernel.registerSemanticFunction";
|
||||
|
||||
public FunctionNotRegisteredException(String name) {
|
||||
super(
|
||||
"It does not appear this function("
|
||||
+ name
|
||||
+ ") has been registered on a kernel.\n"
|
||||
+ "Register it on a kernel either by passing it to"
|
||||
+ " KernelConfig.Builder().addSkill() when building the kernel, or\n"
|
||||
+ "passing it to Kernel.registerSemanticFunction");
|
||||
super(String.format(format, name));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,7 +1,9 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
package com.microsoft.semantickernel.skilldefinition;
|
||||
|
||||
public class FunctionNotFound extends RuntimeException {
|
||||
import com.microsoft.semantickernel.SKException;
|
||||
|
||||
public class FunctionNotFound extends SKException {
|
||||
public FunctionNotFound(String functionName) {
|
||||
super("Could not find function: " + functionName);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
package com.microsoft.semantickernel.templateengine;
|
||||
|
||||
import com.microsoft.semantickernel.diagnostics.SKException;
|
||||
import com.microsoft.semantickernel.SKException;
|
||||
|
||||
public class TemplateException extends SKException {}
|
||||
|
||||
Reference in New Issue
Block a user