handle notices without profiles better in RSS output

This commit is contained in:
Evan Prodromou 2010-07-13 10:42:06 -04:00
parent 1339f1f908
commit ab149755b6

View File

@ -461,6 +461,11 @@ class ApiAction extends Action
function twitterRssEntryArray($notice) function twitterRssEntryArray($notice)
{ {
$profile = $notice->getProfile(); $profile = $notice->getProfile();
if (empty($profile)) {
throw new ServerException(sprintf(_('No such profile: %d'), $notice->profile_id));
}
$entry = array(); $entry = array();
// We trim() to avoid extraneous whitespace in the output // We trim() to avoid extraneous whitespace in the output
@ -789,13 +794,23 @@ class ApiAction extends Action
if (is_array($notice)) { if (is_array($notice)) {
foreach ($notice as $n) { foreach ($notice as $n) {
try {
$entry = $this->twitterRssEntryArray($n); $entry = $this->twitterRssEntryArray($n);
$this->showTwitterRssItem($entry); $this->showTwitterRssItem($entry);
} catch (Exception $e) {
common_log(LOG_ERR, "Error with notice {$n->id}: " . $e->getMessage());
// continue on exceptions
}
} }
} else { } else {
while ($notice->fetch()) { while ($notice->fetch()) {
try {
$entry = $this->twitterRssEntryArray($notice); $entry = $this->twitterRssEntryArray($notice);
$this->showTwitterRssItem($entry); $this->showTwitterRssItem($entry);
} catch (Exception $e) {
common_log(LOG_ERR, "Error with notice {$n->id}: " . $e->getMessage());
// continue on exceptions
}
} }
} }