Exceptions are caught and continued on JSON, XML, Atom and RSS output in API

This commit is contained in:
Evan Prodromou 2010-07-13 11:11:29 -04:00
parent 1044f27e47
commit 453a06fff4

View File

@ -734,14 +734,16 @@ class ApiAction extends Action
'xmlns:statusnet' => 'http://status.net/schema/api/1/')); 'xmlns:statusnet' => 'http://status.net/schema/api/1/'));
if (is_array($notice)) { if (is_array($notice)) {
foreach ($notice as $n) { $notice = new ArrayWrapper($notice);
$twitter_status = $this->twitterStatusArray($n);
$this->showTwitterXmlStatus($twitter_status);
} }
} else {
while ($notice->fetch()) { while ($notice->fetch()) {
try {
$twitter_status = $this->twitterStatusArray($notice); $twitter_status = $this->twitterStatusArray($notice);
$this->showTwitterXmlStatus($twitter_status); $this->showTwitterXmlStatus($twitter_status);
} catch (Exception $e) {
common_log(LOG_ERR, $e->getMessage());
continue;
} }
} }
@ -789,16 +791,9 @@ class ApiAction extends Action
$this->element('ttl', null, '40'); $this->element('ttl', null, '40');
if (is_array($notice)) { if (is_array($notice)) {
foreach ($notice as $n) { $notice = new ArrayWrapper($notice);
try {
$entry = $this->twitterRssEntryArray($n);
$this->showTwitterRssItem($entry);
} catch (Exception $e) {
common_log(LOG_ERR, $e->getMessage());
// continue on exceptions
} }
}
} else {
while ($notice->fetch()) { while ($notice->fetch()) {
try { try {
$entry = $this->twitterRssEntryArray($notice); $entry = $this->twitterRssEntryArray($notice);
@ -808,7 +803,6 @@ class ApiAction extends Action
// continue on exceptions // continue on exceptions
} }
} }
}
$this->endTwitterRss(); $this->endTwitterRss();
} }
@ -842,12 +836,15 @@ class ApiAction extends Action
$this->element('subtitle', null, $subtitle); $this->element('subtitle', null, $subtitle);
if (is_array($notice)) { if (is_array($notice)) {
foreach ($notice as $n) { $notice = new ArrayWrapper($notice);
$this->raw($n->asAtomEntry());
} }
} else {
while ($notice->fetch()) { while ($notice->fetch()) {
try {
$this->raw($notice->asAtomEntry()); $this->raw($notice->asAtomEntry());
} catch (Exception $e) {
common_log(LOG_ERR, $e->getMessage());
continue;
} }
} }
@ -1042,14 +1039,16 @@ class ApiAction extends Action
$statuses = array(); $statuses = array();
if (is_array($notice)) { if (is_array($notice)) {
foreach ($notice as $n) { $notice = new ArrayWrapper($notice);
$twitter_status = $this->twitterStatusArray($n);
array_push($statuses, $twitter_status);
} }
} else {
while ($notice->fetch()) { while ($notice->fetch()) {
try {
$twitter_status = $this->twitterStatusArray($notice); $twitter_status = $this->twitterStatusArray($notice);
array_push($statuses, $twitter_status); array_push($statuses, $twitter_status);
} catch (Exception $e) {
common_log(LOG_ERR, $e->getMessage());
continue;
} }
} }