|
|
@@ -71,12 +71,30 @@ namespace molilian.core
|
|
|
client.UserAgent = useragent;
|
|
|
client.AddHeaders("Cookie", cookies);
|
|
|
client.Post(data);
|
|
|
- var response = await client.RequestAsync(url, "POST", cancellationToken);
|
|
|
-
|
|
|
- string body = response.Body();
|
|
|
- //{"success":false,"errorCode":43001,"errorMsg":"会话已过期","result":null}
|
|
|
-
|
|
|
-
|
|
|
+ var response = await client.RequestAsync(url, "POST", cancellationToken);
|
|
|
+
|
|
|
+ string body = response.Body();
|
|
|
+ //{"success":false,"errorCode":43001,"errorMsg":"会话已过期","result":null}
|
|
|
+
|
|
|
+ string statusCode = response.ResponseMessage == null
|
|
|
+ ? "No response"
|
|
|
+ : $"{(int)response.ResponseMessage.StatusCode} {response.ResponseMessage.ReasonPhrase}";
|
|
|
+ string responseBody = string.IsNullOrWhiteSpace(body) ? "<empty>" : body;
|
|
|
+
|
|
|
+ if (!response.Successed || response.ResponseMessage?.IsSuccessStatusCode != true)
|
|
|
+ {
|
|
|
+ string httpError = response.ResponseException?.Message ?? "<none>";
|
|
|
+ string httpFailureMessage = $"PDD transferUrl HTTP request failed.\nStatus: {statusCode}\nError: {httpError}\nBody:\n{responseBody}";
|
|
|
+
|
|
|
+ await new LoggerLibrary("PddUnion", "transferUrl.HttpError")
|
|
|
+ .Info(httpFailureMessage, response.ResponseException?.StackTrace)
|
|
|
+ .SaveAsync();
|
|
|
+ throw new HttpRequestException(
|
|
|
+ httpFailureMessage,
|
|
|
+ response.ResponseException,
|
|
|
+ response.ResponseMessage?.StatusCode);
|
|
|
+ }
|
|
|
+
|
|
|
PddTransferUrlResponse root;
|
|
|
try
|
|
|
{
|
|
|
@@ -88,11 +106,13 @@ namespace molilian.core
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
+ string deserializeFailureMessage = $"PDD transferUrl response deserialization failed.\nStatus: {statusCode}\nBody:\n{responseBody}";
|
|
|
+
|
|
|
await new LoggerLibrary("PddUnion", "transferUrl.DeserializeError")
|
|
|
- .Info(body)
|
|
|
+ .Info(deserializeFailureMessage)
|
|
|
.Info(ex.Message, ex.StackTrace)
|
|
|
.SaveAsync();
|
|
|
- throw new InvalidOperationException(body, ex);
|
|
|
+ throw new InvalidOperationException(deserializeFailureMessage, ex);
|
|
|
}
|
|
|
|
|
|
string message = string.Empty;
|