From 9764740030c0f983c7fcf0b793132197fa5d26e4 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Fri, 6 Dec 2024 11:38:28 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/Dlhis.Jip.Api/ResultHandlers/DHRResultHandler.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Src/Dlhis.Jip.Api/ResultHandlers/DHRResultHandler.cs b/Src/Dlhis.Jip.Api/ResultHandlers/DHRResultHandler.cs index 0ca443f9..6a0f35c4 100644 --- a/Src/Dlhis.Jip.Api/ResultHandlers/DHRResultHandler.cs +++ b/Src/Dlhis.Jip.Api/ResultHandlers/DHRResultHandler.cs @@ -12,9 +12,16 @@ public class DHRResultHandler : IRemoteCallResultHandler public TResult Handle(HttpStatusCode statusCode, string responseBody) { var apiResult = JsonConvert.DeserializeObject>(responseBody); - if (statusCode != HttpStatusCode.OK || apiResult.Code != 200) + + var isSuccessStatusCode = ((int)statusCode >= 200) && ((int)statusCode <= 299); + if (!isSuccessStatusCode || apiResult.Code != 200) { - throw new Exception(apiResult?.Message); + if (!string.IsNullOrEmpty(apiResult?.Message)) + { + throw new Exception(apiResult.Message); + } + + throw new HttpRequestException(statusCode + " " + (int)statusCode); } return responseBody.Adapt();