From b924144343a39dd264fb085c1cc20506632efc2d Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 13 Mar 2026 15:40:10 +0800 Subject: [PATCH] fix: Add SSE error log recording --- .../AspNetCore/Mvc/SseAsyncEnumerableResult.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.HttpApi/Microsoft/AspNetCore/Mvc/SseAsyncEnumerableResult.cs b/aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.HttpApi/Microsoft/AspNetCore/Mvc/SseAsyncEnumerableResult.cs index 11eb46992..e5707ccc0 100644 --- a/aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.HttpApi/Microsoft/AspNetCore/Mvc/SseAsyncEnumerableResult.cs +++ b/aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.HttpApi/Microsoft/AspNetCore/Mvc/SseAsyncEnumerableResult.cs @@ -1,8 +1,10 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using System; using System.Collections.Generic; +using System.Text; using System.Threading.Tasks; using Volo.Abp.AspNetCore.ExceptionHandling; using Volo.Abp.Http; @@ -49,6 +51,7 @@ public class SseAsyncEnumerableResult : IActionResult catch (Exception ex) { var exceptionHandlingOptions = context.HttpContext.RequestServices.GetRequiredService>().Value; + var exceptionToErrorInfoConverter = context.HttpContext.RequestServices.GetRequiredService(); var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(ex, options => { @@ -57,6 +60,14 @@ public class SseAsyncEnumerableResult : IActionResult options.SendStackTraceToClients = exceptionHandlingOptions.SendStackTraceToClients; }); + if (exceptionHandlingOptions.ShouldLogException(ex)) + { + var logger = context.HttpContext.RequestServices.GetService>(); + var logLevel = ex.GetLogLevel(); + logger?.LogException(ex, logLevel); + } + + response.Headers.RemoveAll(x => x.Key == "Content-Type"); response.Headers.Append("Content-Type", "application/json"); response.Headers.Append(AbpHttpConsts.AbpErrorFormat, "true");