microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
fix/msal-cache

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.AI/Prompts/ChatPrompt/ChatPrompt.Errors.cs

28lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4namespace Microsoft.Teams.AI.Prompts;
5
6public partial class ChatPrompt<TOptions>
7{
8 public IChatPrompt<TOptions> OnError(Action<Exception> onError)
9 {
10 ErrorEvent += (_, ex) => onError(ex);
11 return this;
12 }
13
14 public IChatPrompt<TOptions> OnError(Func<Exception, Task> onError)
15 {
16 ErrorEvent += (_, ex) =>
17 {
18 _ = onError(ex).ContinueWith(t =>
19 {
20 if (t.IsFaulted)
21 {
22 Logger.Error(t.Exception);
23 }
24 }, TaskScheduler.Default);
25 };
26 return this;
27 }
28}
29