Bug: catch excrption request to engine fail

CR: sonhh (fake)
This commit is contained in:
2021-08-26 16:51:36 +07:00
parent b207d54462
commit 14467d53b5
10 changed files with 124 additions and 79 deletions

View File

@@ -172,22 +172,25 @@ class common extends \yii\db\ActiveRecord {
}
public static function requestToEngine($path, $data) {
return file_get_contents("http://localhost:2305" . $path, false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode($data)
]
$content = @file_get_contents("http://localhost:2305" . $path, false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode($data)
]
]));
if ($content == false)
return ["status" => false];
return ["status" => true, "data" => $content];
}
public static function updateFeature($datas) {
return file_get_contents("http://localhost:2305/update-person", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode($datas)
]
return @file_get_contents("http://localhost:2305/update-person", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode($datas)
]
]));
}