- $fave = Fave::addNew($this->user->getProfile(), $notice);
-
- if (!$fave) {
- // TRANS: Error message text shown when a favorite could not be set.
- $channel->error($this->user, _('Could not create favorite.'));
- return;
- }
-
- // @fixme favorite notification should be triggered
- // at a lower level
-
- $other = User::getKV('id', $notice->profile_id);
-
- if ($other && $other->id != $this->user->id) {
- if ($other->email && $other->emailnotifyfav) {
- require_once INSTALLDIR.'/lib/mail.php';
-
- mail_notify_fave($other, $this->user->getProfile(), $notice);
- }
- }
-
- Fave::blowCacheForProfileId($this->user->id);
+ try {
+ $fave = Fave::addNew($this->user->getProfile(), $notice);
+ } catch (Exception $e) {
+ $channel->error($this->user, $e->getMessage());
+ return;
+ }