fix: [modules] Better error handling for connection problems

pull/6483/head
Jakub Onderka 2020-10-22 13:10:07 +02:00
parent 0ff3e0602c
commit 54fa714c29
1 changed files with 6 additions and 0 deletions

View File

@ -256,6 +256,12 @@ class Module extends AppModel
}
$response = $httpSocket->get($url . $uri, false, $request);
}
if (!$response->isOk()) {
if ($httpSocket->lastError()) {
throw new Exception("Failed to get response from $moduleFamily module " . $httpSocket->lastError());
}
throw new Exception("Failed to get response from $moduleFamily module: HTTP $response->reasonPhrase", (int)$response->code);
}
return $this->jsonDecode($response->body);
} catch (Exception $e) {
$this->logException('Failed to query module ' . $moduleFamily, $e);