summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-04-10 21:43:53 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-04-10 21:43:53 +0200
commit42100a83223b93060eedc482eda94a890ee01e4a (patch)
treecf31ac7e6ff53bcd37f83f707d99f633c736b29a
parenta88e61ca1ed1fa1ff145aa1feae10e9529b778bd (diff)
Fix issue #40 : test des erreurs SimplePie
-rw-r--r--app/App_FrontController.php1
-rwxr-xr-xapp/controllers/feedController.php7
-rw-r--r--app/models/Exception/FeedException.php7
-rw-r--r--app/models/Feed.php4
4 files changed, 19 insertions, 0 deletions
diff --git a/app/App_FrontController.php b/app/App_FrontController.php
index fff238bf2..8a5dcdcba 100644
--- a/app/App_FrontController.php
+++ b/app/App_FrontController.php
@@ -24,6 +24,7 @@ class App_FrontController extends FrontController {
}
private function loadModels () {
+ include (APP_PATH . '/models/Exception/FeedException.php');
include (APP_PATH . '/models/RSSConfiguration.php');
include (APP_PATH . '/models/Days.php');
include (APP_PATH . '/models/Category.php');
diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php
index 812227f89..c205801af 100755
--- a/app/controllers/feedController.php
+++ b/app/controllers/feedController.php
@@ -58,6 +58,13 @@ class feedController extends ActionController {
);
Session::_param ('notification', $notif);
}
+ } catch (FeedException $e) {
+ Log::record ($e->getMessage (), Log::ERROR);
+ $notif = array (
+ 'type' => 'bad',
+ 'content' => 'Un problème interne a été rencontré, le flux n\'a pas pu être ajouté'
+ );
+ Session::_param ('notification', $notif);
} catch (FileNotExistException $e) {
Log::record ($e->getMessage (), Log::ERROR);
// notif
diff --git a/app/models/Exception/FeedException.php b/app/models/Exception/FeedException.php
new file mode 100644
index 000000000..3fe0f4ea0
--- /dev/null
+++ b/app/models/Exception/FeedException.php
@@ -0,0 +1,7 @@
+<?php
+
+class FeedException extends Exception {
+ public function __construct ($message) {
+ parent::__construct ($message);
+ }
+}
diff --git a/app/models/Feed.php b/app/models/Feed.php
index b619aaa97..da75ae8c8 100644
--- a/app/models/Feed.php
+++ b/app/models/Feed.php
@@ -128,6 +128,10 @@ class Feed extends Model {
$feed->set_cache_location (CACHE_PATH);
$feed->init ();
+ if ($feed->error()) {
+ throw new FeedException ($feed->error);
+ }
+
$subscribe_url = $feed->subscribe_url ();
if (!is_null ($subscribe_url) && $subscribe_url != $this->url) {
$this->_url ($subscribe_url);