forked from microsoft/semantic-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exception classes in the API should extend SKException (microsoft#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 😄
- Loading branch information
Showing
10 changed files
with
56 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 31 additions & 1 deletion
32
java/semantickernel-api/src/main/java/com/microsoft/semantickernel/SKException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
java/semantickernel-api/src/main/java/com/microsoft/semantickernel/ai/AIException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
...emantickernel-api/src/main/java/com/microsoft/semantickernel/diagnostics/SKException.java
This file was deleted.
Oops, something went wrong.
4 changes: 3 additions & 1 deletion
4
...rnel-api/src/main/java/com/microsoft/semantickernel/exceptions/NotSupportedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...el-api/src/main/java/com/microsoft/semantickernel/exceptions/SkillsNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 {} |
2 changes: 1 addition & 1 deletion
2
...semantickernel-api/src/main/java/com/microsoft/semantickernel/memory/MemoryException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 10 additions & 8 deletions
18
.../main/java/com/microsoft/semantickernel/orchestration/FunctionNotRegisteredException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...rnel-api/src/main/java/com/microsoft/semantickernel/skilldefinition/FunctionNotFound.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nel-core/src/main/java/com/microsoft/semantickernel/templateengine/TemplateException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 {} |