Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit ca4abe0

Browse files
Merge pull request #192 from CESNET/fix-type-error-rpc-connector
fix: prevent type errors in RPC connector
2 parents 44b8a57 + 5152cbe commit ca4abe0

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

lib/RpcConnector.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ public function get($manager, $method, $params = [])
7575
Logger::debug('perun.RPC: GET call ' . $uri . ' with params: ' . $paramsQuery . ', response : ' .
7676
$json . ' in: ' . $responseTime . 's.');
7777

78+
if ($json === false) {
79+
throw new Exception(
80+
'Cant\'t get response from Perun. Call: ' . $uri . ', Params: ' . $paramsQuery .
81+
', Response: ' . $json
82+
);
83+
}
84+
7885
$result = json_decode($json, true);
7986

8087
if (json_last_error() !== JSON_ERROR_NONE) {
@@ -121,6 +128,13 @@ public function post($manager, $method, $params = [])
121128
Logger::debug('perun.RPC: POST call ' . $uri . ' with params: ' . $paramsJson . ', response : ' .
122129
$json . ' in: ' . $responseTime . 's.');
123130

131+
if ($json === false) {
132+
throw new Exception(
133+
'Can\'t get response from Perun. Call: ' . $uri . ', Params: ' . $paramsQuery .
134+
', Response: ' . $json
135+
);
136+
}
137+
124138
$result = json_decode($json, true);
125139

126140
if (json_last_error() !== JSON_ERROR_NONE) {

0 commit comments

Comments
 (0)