-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename Exception<T>
and have non-generic base
#573
Comments
|
5 tasks
dehoward
pushed a commit
to lemillermicrosoft/semantic-kernel
that referenced
this issue
Jun 1, 2023
…icrosoft#701) ### Motivation and Context Fixes microsoft#573 ### Description - Make the base class non-generic and rename it to SKException - Remove unnecessary private ctors from derived types - Clean up how messages are generated
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The base class for Semantic Kernel exceptions is
Exception<TErrorCode>
. This is too general a name, even though it's part of the Microsoft.SemanticKernel.Diagnostics namespace. Once a developer imports the namespace, catch blocks likecatch (Exception<TErrorCode>)
to catch all SK exceptions look much more broad and general-purpose than it is. At the same time, it's not broad enough to catch all SK exceptions, because it'll only catch those for that specific TErrorCode enum type.Further, the TErrorCode needn't actually be part of the exception's identity. The base exception type doesn't store anything of that type, and instead just accepts an instance as a ctor parameter and uses it to build up a message. That can be done just accepting an object; if you're about to throw an exception, one additional allocation to box an enum value doesn't matter.
It'd be better to have just
to address both concerns. Derived exception types can include an error code in whatever message they pass down. If we want a BuildMessage helper to assist with that, it can be an internal / private protected static method on the base exception type.
cc: @dluc, @shawncal
The text was updated successfully, but these errors were encountered: