8.7K Star 14.3K Fork 4.2K

GVPdotNET China/Furion

 / 详情

HttpRequestPart类SendAsync报错

已完成
创建于  
2022-04-26 10:46

💢 特别说明:如果 Issue 没有严格按照模板编写且未提供测试源码下载或 Git 测试仓库地址,则视为无效 Issue

Furion 版本号

哪个版本号?


Web 项目类型

  • WebApi
  • Mvc
  • Razor Pages
  • Blazor Server
  • MinApp

描述你的问题

SendAsync出异常后,如果OnRequestFailded没有赋值,会出现空引用

try
   {
    if (RetryPolicy == null) response = await httpClient.SendAsync(request, cancellationToken);
    else
    {
        // 失败重试
        await Retry.Invoke(async () =>
        {
            // 发送请求
            response = await httpClient.SendAsync(request, cancellationToken);
        }, RetryPolicy.Value.NumRetries, RetryPolicy.Value.RetryTimeout);
    }
}
catch (Exception ex)
{
    // 触发自定义事件
    if (response != null) OnRequestFailded(this, new HttpRequestFaildedEventArgs(request, response, ex));

    exception = ex;
}

异常堆栈信息

System.NullReferenceException:“Object reference not set to an instance of an object.”

测试项目代码

⚠⚠ 必须提供完整可运行且包含错误的 Git 仓库 DEMO,DEMO 提供最简单的错误逻辑代码,否则不予处理。⚠⚠

您的代码下载地址?


数据库信息

  • Sqlite
  • SqlServer
  • Mysql
  • Oracle
  • PGSql
  • Firebird
  • Cosmos

期待结果

先判断OnRequestFailded是否为空,再调用失败事件


评论 (2)

小苏打饼。 创建了任务 3年前
小苏打饼。 修改了描述 3年前
展开全部操作日志

麻烦提供 Furion 版本号,还有详细异常堆栈信息

百小僧 任务状态待办的 修改为已完成 3年前

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(2)
974299 monksoul 1578937227 小苏打饼。-1961117443
C#
1
https://gitee.com/dotnetchina/Furion.git
git@gitee.com:dotnetchina/Furion.git
dotnetchina
Furion
Furion

搜索帮助