From 0726dcd06c122083b1977462b69fe91ac19290fc Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Tue, 2 Jun 2015 13:50:52 +0200 Subject: [PATCH] Start using NoParentNoticeException more widely --- classes/Notice.php | 6 +++--- lib/apiaction.php | 2 +- lib/implugin.php | 2 +- lib/util.php | 4 ++-- plugins/Xmpp/XmppPlugin.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 4d57c5a8db..49c6801ae7 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1311,7 +1311,7 @@ class Notice extends Managed_DataObject $last = $parent; continue; } - } catch (Exception $e) { + } catch (NoParentNoticeException $e) { // Latest notice has no parent } // No parent, or parent out of scope @@ -1617,7 +1617,7 @@ class Notice extends Managed_DataObject $this->saveReply($parentauthor->id); $replied[$parentauthor->id] = 1; self::blow('reply:stream:%d', $parentauthor->id); - } catch (Exception $e) { + } catch (NoParentNoticeException $e) { // Not a reply, since it has no parent! } @@ -1852,7 +1852,7 @@ class Notice extends Managed_DataObject $reply = $this->getParent(); $ctx->replyToID = $reply->getUri(); $ctx->replyToUrl = $reply->getUrl(); - } catch (Exception $e) { + } catch (NoParentNoticeException $e) { // This is not a reply to something } diff --git a/lib/apiaction.php b/lib/apiaction.php index 0eea08bed6..724447f120 100755 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -328,7 +328,7 @@ class ApiAction extends Action // different story for parenting. $parent = $notice->getParent(); $in_reply_to = $parent->id; - } catch (Exception $e) { + } catch (NoParentNoticeException $e) { $in_reply_to = null; } $twitter_status['in_reply_to_status_id'] = $in_reply_to; diff --git a/lib/implugin.php b/lib/implugin.php index 5b0f3dbe09..98fba19911 100644 --- a/lib/implugin.php +++ b/lib/implugin.php @@ -380,7 +380,7 @@ abstract class ImPlugin extends Plugin $parent = $notice->getParent(); $orig_profile = $parent->getProfile(); $nicknames = sprintf('%1$s => %2$s', $profile->nickname, $orig_profile->nickname); - } catch (Exception $e) { + } catch (NoParentNoticeException $e) { $nicknames = $profile->nickname; } diff --git a/lib/util.php b/lib/util.php index 395fadfbd7..f29d9559b9 100644 --- a/lib/util.php +++ b/lib/util.php @@ -725,8 +725,8 @@ function common_find_mentions($text, Notice $notice) } } catch (NoProfileException $e) { common_log(LOG_WARNING, sprintf('Notice %d author profile id %d does not exist', $origNotice->id, $origNotice->profile_id)); - } catch (ServerException $e) { - // Probably just no parent. Should get a specific NoParentException + } catch (NoParentNoticeException $e) { + // This notice is not in reply to anything } catch (Exception $e) { common_log(LOG_WARNING, __METHOD__ . ' got exception ' . get_class($e) . ' : ' . $e->getMessage()); } diff --git a/plugins/Xmpp/XmppPlugin.php b/plugins/Xmpp/XmppPlugin.php index 2974e8b2ab..d95ffcf0d6 100644 --- a/plugins/Xmpp/XmppPlugin.php +++ b/plugins/Xmpp/XmppPlugin.php @@ -354,7 +354,7 @@ class XmppPlugin extends ImPlugin $xs->text(": "); } catch (InvalidUrlException $e) { $xs->text(sprintf(' => %s', $orig_profile->nickname)); - } catch (Exception $e) { + } catch (NoParentNoticeException $e) { $xs->text(": "); } if (!empty($notice->rendered)) { -- 2.39.5