-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Use such code snippet in program.cs
to have bot send an general message back to users if there is any error happens. However the context is null so that I cannot send message back.
Repro steps:
- Open Samples.Echo
- Replace the main method with the content below
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();
//builder.Services.AddTransient<Controller>();
builder.AddTeams().AddTeamsDevTools();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.UseHttpsRedirection();
var teamsApp = app.UseTeams();
teamsApp.OnMessage(async (context) =>
{
throw new Exception("test exception");
});
teamsApp.OnError(async (sender, @event) =>
{
Console.WriteLine("!!OnError HIT!!");
var context = @event.Context;
await context.Send($"The bot encountered an unhandled error: {@event.Exception.Message}");
teamsApp.Logger.Error($"[OnError] unhandled error : {@event.Exception.Message}");
});
app.Run();
}
- context is null that cannot send message.
Metadata
Metadata
Assignees
Labels
No labels