Skip to content

Commit

Permalink
Merge pull request #20595 from abpframework/auto-merge/rel-8-3/2932
Browse files Browse the repository at this point in the history
Merge branch dev with rel-8.3
  • Loading branch information
maliming authored Aug 22, 2024
2 parents 85d808e + 32c68f1 commit af472dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,18 @@ await context.HttpContext.RequestServices.GetRequiredService<IAbpAuthorizationEx
}
else
{
context.HttpContext.Response.Headers.Add(AbpHttpConsts.AbpErrorFormat, "true");
context.HttpContext.Response.StatusCode = (int)context
.GetRequiredService<IHttpExceptionStatusCodeFinder>()
.GetStatusCode(context.HttpContext, context.Exception);
if (!context.HttpContext.Response.HasStarted)
{
context.HttpContext.Response.Headers.Add(AbpHttpConsts.AbpErrorFormat, "true");
context.HttpContext.Response.StatusCode = (int)context
.GetRequiredService<IHttpExceptionStatusCodeFinder>()
.GetStatusCode(context.HttpContext, context.Exception);
}
else
{
var logger = context.GetService<ILogger<AbpExceptionFilter>>(NullLogger<AbpExceptionFilter>.Instance)!;
logger.LogWarning("HTTP response has already started, cannot set headers and status code!");
}

context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,17 @@ await context.HttpContext.RequestServices.GetRequiredService<IAbpAuthorizationEx
}
else
{
context.HttpContext.Response.Headers.Add(AbpHttpConsts.AbpErrorFormat, "true");
context.HttpContext.Response.StatusCode = (int)context
.GetRequiredService<IHttpExceptionStatusCodeFinder>()
.GetStatusCode(context.HttpContext, context.Exception!);
if (!context.HttpContext.Response.HasStarted)
{
context.HttpContext.Response.Headers.Add(AbpHttpConsts.AbpErrorFormat, "true");
context.HttpContext.Response.StatusCode = (int)context
.GetRequiredService<IHttpExceptionStatusCodeFinder>()
.GetStatusCode(context.HttpContext, context.Exception!);
}
else
{
logger.LogWarning("HTTP response has already started, cannot set headers and status code!");
}

context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo));
}
Expand Down

0 comments on commit af472dd

Please sign in to comment.