Skip to content
Snippets Groups Projects
Commit 5bd589bc authored by Alex Barth's avatar Alex Barth
Browse files

Handle exceptions outside of Importer/Source facade methods.

parent a8b6bb31
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
......
......@@ -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);
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment