{"id":1251,"date":"2023-09-21T14:16:24","date_gmt":"2023-09-21T21:16:24","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/semantic-kernel\/?p=1251"},"modified":"2023-09-21T14:16:24","modified_gmt":"2023-09-21T21:16:24","slug":"save-time-with-semantic-kernels-updated-error-handling","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/agent-framework\/save-time-with-semantic-kernels-updated-error-handling\/","title":{"rendered":"Save Time with Semantic Kernel\u2019s Updated Error Handling"},"content":{"rendered":"<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-89\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternlarge.png\" alt=\"Image skpatternlarge\" width=\"1638\" height=\"136\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternlarge.png 1638w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternlarge-300x25.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternlarge-1024x85.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternlarge-768x64.png 768w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternlarge-1536x128.png 1536w\" sizes=\"(max-width: 1638px) 100vw, 1638px\" \/><\/p>\n<p>Error handling is an essential aspect of application development. It ensures that applications can gracefully handle unexpected situations and provide meaningful feedback to users. In this blog post, we will explore the recent improvements made by the team to the error handling mechanism in the Semantic Kernel (SK) .net library.<\/p>\n<h2>SKException: Making Error Handling Easier<\/h2>\n<p>One of the key changes introduced by the team is greater coverage and use of the SKException class. The exception hierarchy has been carefully flattened and 17 custom exception classes have been removed. SK now only has two, SKException and HttpOperationException. For example, you may previously used the AzureSearchMemoryException for error handling, which has now been replaced by SKException. These updates provide a more intuitive and streamlined approach to error handling.<\/p>\n<h2>Streamlining Connectors<\/h2>\n<p>The team has made significant changes to various connectors used in SK, such as RedisMemoryStore, GrpcOperationRunner, ProtoDocumentParser, PineconeMemoryStore, QdrantMemoryStore, WeaviateMemoryStore and more. These connectors now throw SKException instead of their dedicated exceptions, resulting in a more consistent and unified error handling experience.<\/p>\n<h2>Enhancements to SK Components<\/h2>\n<p>To further improve error handling, the team has updated various SK components to throw SKException instead of KernelException and OpenAIInvalidResponseException. This change ensures that exceptions are handled uniformly across different parts of the SK library. Additionally, the template engine functionality has been updated to throw SKException instead of TemplateException, simplifying error handling for template-related issues. The SK planners functionality has been enhanced to throw SKException instead of PlanningException, resulting in a more cohesive error handling approach.<\/p>\n<h2>Introducing HttpOperationException<\/h2>\n<p>To handle HTTP-related exceptions more uniformly, we introduced the `HttpOperationException`. This exception class replaces the `AIException` class, which was previously used for both HTTP-related and unrelated cases, the `HttpRequestException` that was thrown by a few core skills, and the `RequestFailedException` that was used by the `AzureCognitiveSearchMemoryStore`. This replacement ensures consistent exception handling across SK consumer code.<\/p>\n<h2>Conclusion<\/h2>\n<p>The recent improvements in semantic kernel error handling have significantly enhanced the overall error handling experience for developers using the SK library. With streamlined exception classes, unified error handling across connectors and components, and useful extension methods, developers can now handle errors more effectively and build robust applications with ease.<\/p>\n<p>Please note that this blog post is based on information available up until September 2023 and may not reflect any subsequent updates or changes.<\/p>\n<h2>Next Steps:<\/h2>\n<ul>\n<li>Get the latest SDK version <a href=\"https:\/\/github.com\/microsoft\/semantic-kernel\/pkgs\/nuget\/Microsoft.SemanticKernel\">here<\/a> to benefit from these changes.<\/li>\n<li>Join our <a href=\"aka.ms\/sk-community\">community<\/a> to contribute or if you have questions.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-92\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternsmallbw.png\" alt=\"Image skpatternsmallbw\" width=\"1211\" height=\"137\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternsmallbw.png 1211w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternsmallbw-300x34.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternsmallbw-1024x116.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternsmallbw-768x87.png 768w\" sizes=\"(max-width: 1211px) 100vw, 1211px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Error handling is an essential aspect of application development. It ensures that applications can gracefully handle unexpected situations and provide meaningful feedback to users. In this blog post, we will explore the recent improvements made by the team to the error handling mechanism in the Semantic Kernel (SK) .net library. SKException: Making Error Handling Easier [&hellip;]<\/p>\n","protected":false},"author":116113,"featured_media":1258,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17,1],"tags":[],"class_list":["post-1251","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcements","category-semantic-kernel"],"acf":[],"blog_post_summary":"<p>Error handling is an essential aspect of application development. It ensures that applications can gracefully handle unexpected situations and provide meaningful feedback to users. In this blog post, we will explore the recent improvements made by the team to the error handling mechanism in the Semantic Kernel (SK) .net library. SKException: Making Error Handling Easier [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/1251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/users\/116113"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/comments?post=1251"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/1251\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media\/1258"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media?parent=1251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/categories?post=1251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/tags?post=1251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}