Skip to content

Commit

Permalink
Http异常响应状态,不应该抛出ApiException异常,因为后者会被认为是业务异常
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Dec 27, 2024
1 parent 3cd4769 commit e8140cd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion NewLife.Core/Remoting/ApiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,13 @@ public static HttpContent BuildContent(IPacket data)
}
if (msg.IsNullOrEmpty()) msg = response.ReasonPhrase;
if (msg.IsNullOrEmpty()) msg = response.StatusCode + "";
throw new ApiException((Int32)response.StatusCode, msg);
//throw new ApiException((Int32)response.StatusCode, msg);
// Http异常响应状态,不应该抛出ApiException异常,因为后者会被认为是业务异常
#if NET5_0_OR_GREATER
throw new HttpRequestException(msg, null, response.StatusCode);
#else
throw new HttpRequestException(msg);
#endif
}
if (buf == null || buf.Length == 0) return default;

Expand Down

0 comments on commit e8140cd

Please sign in to comment.