Don't throw exception if bookmark has no attachments; log error and render as normal notice instead.

This commit is contained in:
Zach Copley 2011-09-30 18:13:25 +00:00
parent ba4bda9beb
commit fd62f6b934

View File

@ -68,13 +68,24 @@ class BookmarkListItem extends NoticeListItemAdapter
$atts = $notice->attachments();
if (count($atts) < 1) {
// Something wrong; let default code deal with it.
// TRANS: Exception thrown when a bookmark has no attachments.
// TRANS: %1$s is a bookmark ID, %2$s is a notice ID (number).
throw new Exception(sprintf(_m('Bookmark %1$s (notice %2$d) has no attachments.'),
if (empty($atts)) {
// Something went wrong!
common_log(
LOG_ERR,
sprintf(
_m('Bookmark %1$s (notice %2$d) has no attachments.'),
$nb->id,
$notice->id));
$notice->id
)
);
// try to show the notice as plain text
parent::showContent();
return;
}
$att = $atts[0];