Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/undo-ransomware/ransomware_detection.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Held <ilovemilk@wusa.io>2019-07-06 17:57:03 +0300
committerMatthias Held <ilovemilk@wusa.io>2019-07-06 17:57:03 +0300
commitc9cbe77db3c4802f333fda87599f1263b86ebe52 (patch)
treef2f38a27cca2c49d7af24a3d0262b68ce3f6351c
parente61a0308c3f95b861bf1de83c9c8715fd138bbbc (diff)
handle the exception thrown if there is no connection
-rw-r--r--lib/Monitor.php34
1 files changed, 25 insertions, 9 deletions
diff --git a/lib/Monitor.php b/lib/Monitor.php
index baefbe4..7a19176 100644
--- a/lib/Monitor.php
+++ b/lib/Monitor.php
@@ -38,6 +38,7 @@ use OCP\Notification\IManager;
use OCP\IConfig;
use OCP\ILogger;
use OCP\IRequest;
+use GuzzleHttp\Exception\ConnectException;
class Monitor
{
@@ -239,9 +240,14 @@ class Monitor
$entity = $this->mapper->insert($fileOperation);
$serviceUri = $this->config->getAppValue(Application::APP_ID, 'service_uri', 'http://localhost:5000');
- $result = RequestTemplate::post($serviceUri . "/file-operation", $entity);
- if ($result->getStatusCode() !== 200) {
- $this->logger->error("The detection service is not working correctly.");
+ try {
+ $result = RequestTemplate::post($serviceUri . "/file-operation", $entity);
+ if ($result->getStatusCode() !== 200) {
+ $this->logger->error("The detection service is not working correctly.");
+ }
+ } catch (ConnectionException $ex) {
+ //TODO: Notify the use by the Notifier
+ $this->logger->error("No connection to the detection service.");
}
$this->nestingLevel--;
@@ -368,9 +374,14 @@ class Monitor
$entity = $this->mapper->insert($fileOperation);
$serviceUri = $this->config->getAppValue(Application::APP_ID, 'service_uri', 'http://localhost:5000');
- $result = RequestTemplate::post($serviceUri . "/file-operation", $entity);
- if ($result->getStatusCode() !== 200) {
- $this->logger->error("The detection service is not working correctly.");
+ try {
+ $result = RequestTemplate::post($serviceUri . "/file-operation", $entity);
+ if ($result->getStatusCode() !== 200) {
+ $this->logger->error("The detection service is not working correctly.");
+ }
+ } catch (ConnectionException $ex) {
+ //TODO: Notify the use by the Notifier
+ $this->logger->error("No connection to the detection service.");
}
}
@@ -405,9 +416,14 @@ class Monitor
$entity = $this->mapper->insert($fileOperation);
$serviceUri = $this->config->getAppValue(Application::APP_ID, 'service_uri', 'http://localhost:5000');
- $result = RequestTemplate::post($serviceUri . "/file-operation", $entity);
- if ($result->getStatusCode() !== 200) {
- $this->logger->error("The detection service is not working correctly.");
+ try {
+ $result = RequestTemplate::post($serviceUri . "/file-operation", $entity);
+ if ($result->getStatusCode() !== 200) {
+ $this->logger->error("The detection service is not working correctly.");
+ }
+ } catch (ConnectionException $ex) {
+ //TODO: Notify the use by the Notifier
+ $this->logger->error("No connection to the detection service.");
}
}
}