From 5bd589bc97dc402aeb60b0e8b35ef6bf5a6e97ed Mon Sep 17 00:00:00 2001 From: Alex Barth <alex_b@53995.no-reply.drupal.org> Date: Thu, 11 Feb 2010 00:26:49 +0000 Subject: [PATCH] Handle exceptions outside of Importer/Source facade methods. --- includes/FeedsImporter.inc | 14 +++++++------- includes/FeedsScheduler.inc | 1 + includes/FeedsSource.inc | 15 +++++++++------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/includes/FeedsImporter.inc b/includes/FeedsImporter.inc index 2ba2aea6..19861053 100644 --- a/includes/FeedsImporter.inc +++ b/includes/FeedsImporter.inc @@ -73,15 +73,12 @@ class FeedsImporter extends FeedsConfigurable { * @return * FEEDS_BATCH_COMPLETE if complete, a float between 0 and 1 indicating * progress otherwise. + * + * @throws + * Throws Exception if an error occurs when expiring items. */ public function expire($time = NULL) { - try { - return $this->processor->expire($time); - } - catch (Exception $e) { - drupal_set_message($e->getMessage(), 'error'); - return FEEDS_BATCH_COMPLETE; - } + return $this->processor->expire($time); } /** @@ -96,6 +93,9 @@ class FeedsImporter extends FeedsConfigurable { * @return * FEEDS_BATCH_COMPLETE if complete, a float between 0 and 1 indicating * progress otherwise. + * + * @throws + * Throws Exception if an error occurs working off the job. */ public function work($job) { if ($this->export_type == FEEDS_EXPORT_NONE) { diff --git a/includes/FeedsScheduler.inc b/includes/FeedsScheduler.inc index 82bea271..7adebec5 100644 --- a/includes/FeedsScheduler.inc +++ b/includes/FeedsScheduler.inc @@ -165,6 +165,7 @@ class FeedsScheduler implements FeedsSchedulerInterface { } catch (Exception $e) { watchdog('FeedsScheduler', $e->getMessage(), array(), WATCHDOG_ERROR); + $this->finished($job); } // Make sure that job is not scheduled after this method has executed. $this->unschedule($job); diff --git a/includes/FeedsSource.inc b/includes/FeedsSource.inc index c0191e8f..320a3643 100644 --- a/includes/FeedsSource.inc +++ b/includes/FeedsSource.inc @@ -108,8 +108,8 @@ class FeedsSource extends FeedsConfigurable { * Lock a source before importing by using FeedsSource::lock(), after * importing, release with FeedsSource::release(). * - * @todo Iron out and document potential Exceptions. - * @todo catch exceptions outside of import(), clear() and expire(). + * @throws + * Throws Exception if an error occurs when importing. */ public function import() { try { @@ -125,8 +125,8 @@ class FeedsSource extends FeedsConfigurable { } catch (Exception $e) { unset($this->batch); - $result = FEEDS_BATCH_ACTIVE; - drupal_set_message($e->getMessage(), 'error'); + $this->save(); + throw $e; } $this->save(); return $result; @@ -134,6 +134,9 @@ class FeedsSource extends FeedsConfigurable { /** * Remove all items from a feed. + * + * @throws + * Throws Exception if an error occurs when clearing. */ public function clear() { try { @@ -149,8 +152,8 @@ class FeedsSource extends FeedsConfigurable { } catch (Exception $e) { unset($this->batch); - $result = FEEDS_BATCH_COMPLETE; - drupal_set_message($e->getMessage(), 'error'); + $this->save(); + throw $e; } $this->save(); return $result; -- GitLab