Ver código fonte

添加coinex订单格式化异常捕获打印

JiahengHe 1 ano atrás
pai
commit
a04e89c877
1 arquivos alterados com 12 adições e 1 exclusões
  1. 12 1
      standard/src/coinex_swap.rs

+ 12 - 1
standard/src/coinex_swap.rs

@@ -467,6 +467,7 @@ impl Platform for CoinexSwap {
             // info!("cancel_order {} order_id {} custom_id {}", res_data_json, order_id, custom_id);
             let mut result = format_order_item(res_data_json, ct_val, "canceled");
             result.custom_id = custom_id.to_string();
+            result.id = order_id.to_string();
             Ok(result)
         } else {
             let message = format!("撤单HTTP请求失败  order_id: {}, custom_id: {}, res_data: {:?}", order_id, custom_id, res_data);
@@ -684,11 +685,21 @@ pub fn format_order_item(order: Value, ct_val: Decimal, status :&str) -> Order {
             trace_stack: TraceStack::new(0, Instant::now()).on_special("688 trace_stack".to_string()),
         }
     }
+    let size;
+    match order["amount"].as_str() {
+        Some(val) => {
+            size = Decimal::from_str(val).unwrap()
+        },
+        None => {
+            error!("coinex_swap:格式化订单大小错误!\nformat_order_item:order={:?} status={}", order, status);
+            panic!("coinex_swap:格式化订单大小失败,退出程序!");
+        }
+    }
     // info!("order {}", order);
     // 通过客户端id查询订单 只能查出未完成订单(没有状态字段)
     let status = order["status"].as_str().unwrap_or(status);
     let text = order["client_id"].as_str().unwrap_or("");
-    let size = Decimal::from_str(&order["amount"].as_str().unwrap()).unwrap();
+
     let deal_amount = Decimal::from_str(&order["filled_amount"].as_str().unwrap()).unwrap();
     let filled_value = Decimal::from_str(&order["filled_value"].as_str().unwrap()).unwrap();