|
|
@@ -10,7 +10,7 @@ use serde_json::Value;
|
|
|
use crate::http_tool::RestTool;
|
|
|
use crate::response_base::ResponseData;
|
|
|
use sha2::{Digest, Sha256};
|
|
|
-use tracing::{error, info};
|
|
|
+use tracing::error;
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
pub struct CoinexSwapRest {
|
|
|
@@ -636,13 +636,21 @@ impl CoinexSwapRest {
|
|
|
|
|
|
let text = response.text().await.unwrap();
|
|
|
|
|
|
- let data_json: Value = serde_json::from_str(text.as_str()).unwrap();
|
|
|
- return if is_success && data_json["code"].to_string() == "0" {
|
|
|
- self.on_success_data(data_json["data"].clone())
|
|
|
- } else {
|
|
|
- info!("原始http 响应数据:{}", res_json);
|
|
|
- self.on_error_data(&text, &url, &body)
|
|
|
- };
|
|
|
+ let data_json_str: Result<Value, serde_json::Error> = serde_json::from_str(text.as_str());
|
|
|
+ match data_json_str {
|
|
|
+ Ok(data_json) => {
|
|
|
+ return if is_success && data_json["code"].to_string() == "0" {
|
|
|
+ self.on_success_data(data_json["data"].clone())
|
|
|
+ } else {
|
|
|
+ error!("请求成功,code码异常。原始http 响应数据:{}, text: {}", res_json, text);
|
|
|
+ self.on_error_data(&text, &url, &body)
|
|
|
+ };
|
|
|
+ }
|
|
|
+ Err(e) => {
|
|
|
+ error!("请求成功,响应数据异常。原始http 响应数据:{}, text: {}", res_json, text);
|
|
|
+ self.on_error_data(&e.to_string(), &url, &body)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
pub fn on_success_data(&mut self, text: Value) -> ResponseData {
|