Skip to content

Commit

Permalink
status system error
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Feb 20, 2023
1 parent 6b26efd commit 087a683
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/Api/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,21 @@ function __construct(string $exchange,string $key,string $secret,string $extra='
/**
*
* @param
* @param string
* @return array
* */
protected function error($msg){
protected function error($msg,$status='FAILURE'){
if(stripos($msg,'Connection timed out after')!==false){
$httpcode=504;
}

$temp=json_decode($msg,true);
if(!empty($temp) && is_array($temp)) {
if(isset($httpcode)) $temp['_httpcode']=$httpcode;
return ['_error'=>$temp,'_status'=>'FAILURE'];
return ['_error'=>$temp,'_status'=>$status];
}

return ['_error'=>$msg,'_status'=>'FAILURE'];
return ['_error'=>$msg,'_status'=>$status];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Trader.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ function show(array $data){
$trader=$this->map->responseTrader()->show(['result'=>$result,'request'=>$data]);
//print_r($trader);
if(isset($trader['_status'])) {
if(in_array($trader['_status'],['FAILURE'])) return ['_error'=>$trader,'_status'=>'FAILURE'];
if(in_array($trader['_status'],['FAILURE'])) return ['_error'=>$trader];
}

return $trader;
}catch (\Exception $e){
return $this->error($e->getMessage());
return $this->error($e->getMessage(),'system error');
}
}

Expand Down

0 comments on commit 087a683

Please sign in to comment.