diff --git a/STranslateDLL/LocalMode.cs b/STranslateDLL/LocalMode.cs index 4e59c1a..8cfe218 100644 --- a/STranslateDLL/LocalMode.cs +++ b/STranslateDLL/LocalMode.cs @@ -69,12 +69,15 @@ public class LocalMode } var deeplResp = JsonConvert.DeserializeObject(responseBody); + var response = new Response { - Code = resp.StatusCode.GetHashCode(), - Data = deeplResp?.Result?.Texts?.FirstOrDefault()?.Text ?? deeplResp?.Error?.Message ?? "Empty Response" + Code = resp.StatusCode.GetHashCode() }; + string defaultMessage = resp.StatusCode == System.Net.HttpStatusCode.OK ? "Empty Result" : "Empty Error Message"; + response.Data = deeplResp?.Result?.Texts?.FirstOrDefault()?.Text ?? deeplResp?.Error?.Message ?? defaultMessage; + return JsonConvert.SerializeObject(response); }