From 62d3e8b03be823bee65b780e475f5c93a20eb045 Mon Sep 17 00:00:00 2001 From: zhouaini528 <465382251@qq.com> Date: Thu, 21 Dec 2023 13:49:27 +0800 Subject: [PATCH] throw new Exception --- src/Request.php | 2 ++ tests/spot_v2/account.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Request.php b/src/Request.php index 2dc2349..7ad173e 100644 --- a/src/Request.php +++ b/src/Request.php @@ -171,6 +171,8 @@ protected function exec(){ try { return json_decode($this->send(),true); }catch (RequestException $e){ + if(empty($e->getResponse()) || $e->getResponse()==null) throw new Exception(json_encode(['_message'=>'system error'])); + if(method_exists($e->getResponse(),'getBody')){ $contents=$e->getResponse()->getBody()->getContents(); diff --git a/tests/spot_v2/account.php b/tests/spot_v2/account.php index 3255166..15d39ad 100644 --- a/tests/spot_v2/account.php +++ b/tests/spot_v2/account.php @@ -20,7 +20,7 @@ ]); try { - $result=$bitget->account()->getInfo(); + $result=$bitget->account()->getAssets(); print_r($result); }catch (\Exception $e){ print_r(json_decode($e->getMessage(),true));