Skip to content

Commit e8140cd

Browse files
committed
Http异常响应状态,不应该抛出ApiException异常,因为后者会被认为是业务异常
1 parent 3cd4769 commit e8140cd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

NewLife.Core/Remoting/ApiHelper.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,13 @@ public static HttpContent BuildContent(IPacket data)
261261
}
262262
if (msg.IsNullOrEmpty()) msg = response.ReasonPhrase;
263263
if (msg.IsNullOrEmpty()) msg = response.StatusCode + "";
264-
throw new ApiException((Int32)response.StatusCode, msg);
264+
//throw new ApiException((Int32)response.StatusCode, msg);
265+
// Http异常响应状态,不应该抛出ApiException异常,因为后者会被认为是业务异常
266+
#if NET5_0_OR_GREATER
267+
throw new HttpRequestException(msg, null, response.StatusCode);
268+
#else
269+
throw new HttpRequestException(msg);
270+
#endif
265271
}
266272
if (buf == null || buf.Length == 0) return default;
267273

0 commit comments

Comments
 (0)