Skip to content

Commit ce20a68

Browse files
committed
Fixed: error response
1 parent 4a65162 commit ce20a68

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

CPanel.php

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,35 +183,47 @@ public function call($module, $function, $args = array())
183183

184184
curl_close($curl);
185185

186+
$curl_response_decoded = json_decode($curl_res);
187+
186188
$response['inputs']['url'] = $url;
189+
187190
$response['curl_response'] = [
191+
'curl_response' => $curl_res,
192+
'curl_response_decoded' => $curl_response_decoded,
188193
'header_size' => $header_size,
189194
'header' => $header,
190-
'response' => $curl_res,
191195
'body' => $body,
192196
'error' => $err,
193197
'err_no' => $err_no,
194198
];
195199

200+
201+
196202
if ($err || $err_no) {
197203

198204
$response['status'] = 'failed';
199205
$response['errors'] = $err;
200206

201-
} else {
202-
203-
if(isset($res) && isset($res->status) && $res->status == 0)
204-
{
205-
$response['status'] = 'failed';
206-
$response['errors'][] = $res->errors;
207-
$response['inputs']['url'] = $url;
208-
} else
209-
{
210-
$response['data'] = json_decode($curl_res);
211-
$response['status'] = 'success';
212-
$response['inputs']['url'] = $url;
213-
}
207+
} if(isset($curl_response_decoded->errors) && count($curl_response_decoded->errors) > 0)
208+
{
209+
$response['status'] = 'failed';
210+
$response['errors'] = $curl_response_decoded->errors;
211+
212+
} else {
213+
214+
if(isset($res) && isset($res->status) && $res->status == 0)
215+
{
216+
$response['status'] = 'failed';
217+
$response['errors'][] = $res->errors;
218+
$response['inputs']['url'] = $url;
219+
} else
220+
{
221+
$response['data'] = json_decode($curl_res);
222+
$response['status'] = 'success';
223+
$response['inputs']['url'] = $url;
214224
}
225+
}
226+
215227

216228
return $response;
217229
}

0 commit comments

Comments
 (0)