diff --git a/lib/Jaklis.class.php b/lib/Jaklis.class.php index c0cdc7c..e619e87 100644 --- a/lib/Jaklis.class.php +++ b/lib/Jaklis.class.php @@ -32,11 +32,17 @@ class Jaklis { if ($this->mode = 'local') { - return [ + try { - $this->getInboundMessages(), - $this->getOutboundMessages() - ]; + $msg_in = $this->getInboundMessages(); + $msg_out = $this->getOutboundMessages(); + + } catch (Exception $errMsg) { + + throw Exception($errMsg); + } + + return [$msg_in, $msg_out]; } else { @@ -57,6 +63,11 @@ class Jaklis { $result_code=null; exec($cmd, $output, $result_code); + if (empty($output)) { + + throw Exception('Jaklis marche pô pour les messages entrants.'); + } + $json = implode("\n", $output); // echo '

' . $cmd . '

'; @@ -83,6 +94,11 @@ class Jaklis { $result_code=null; exec($cmd, $output, $result_code); + if (empty($output)) { + + throw Exception('Jaklis marche pô pour les messages sortants.'); + } + $json = implode("\n", $output); // echo '

' . $cmd . '

'; diff --git a/messenger.php b/messenger.php index 6430480..44e5153 100644 --- a/messenger.php +++ b/messenger.php @@ -5,6 +5,7 @@ require_once('lib/Fred.class.php'); require_once('lib/Messenger.class.php'); require_once('lib/Gchange.class.php'); require_once('lib/Jaklis.class.php'); +require_once('lib/ErrorsHandler.php'); $gchange = new Gchange(); $messenger = new Messenger($gchange); @@ -24,7 +25,15 @@ if (isset($_POST['message'], $_POST['to'])) { } // $msgIn = $jaklis->getInboundMessages('QP1VkfaFUMdHZmHgPMi7q5wJJHaQhZcEqs5A86NigKr'); -list($msgIn, $msgOut) = $jaklis->getMessages(); +try { + + list($msgIn, $msgOut) = $jaklis->getMessages(); + +} catch (Exception $errMsg) { + + ErrorsHandler::kaput($errMsg); +} + // list($msgIn, $msgOut) = $fred->donneMoiSesPutainDeMessagesGchange($_SESSION['salt'], $_SESSION['pepper']); // echo '
'; var_dump($msgIn); echo '
';