From: Mikael Nordfeldth Date: Mon, 1 May 2017 05:40:16 +0000 (+0200) Subject: Message to end-user on why FeedSub failed. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=37c97ac8fc4e769f711987ed75da39982d27307b;p=quix0rs-gnu-social.git Message to end-user on why FeedSub failed. --- diff --git a/plugins/OStatus/classes/FeedSub.php b/plugins/OStatus/classes/FeedSub.php index 7bbd6b5694..3972d74eaa 100644 --- a/plugins/OStatus/classes/FeedSub.php +++ b/plugins/OStatus/classes/FeedSub.php @@ -393,6 +393,8 @@ class FeedSub extends Managed_DataObject */ protected function doSubscribe($mode) { + $msg = null; // carries descriptive error message to enduser (no remote data strings!) + $orig = clone($this); if ($mode == 'subscribe') { $this->secret = common_random_hexstr(32); @@ -435,6 +437,7 @@ class FeedSub extends Managed_DataObject return; } else if ($status >= 200 && $status < 300) { common_log(LOG_ERR, __METHOD__ . ": sub req returned unexpected HTTP $status: " . $response->getBody()); + $msg = sprintf(_m("Unexpected HTTP status: %d"), $status); } else if ($status == 422) { // Error code regarding something wrong in the data (it seems // that we're talking to a PuSH hub at least, so let's check @@ -455,7 +458,7 @@ class FeedSub extends Managed_DataObject // Throw the Exception again. throw $e; } - throw new ServerException("{$mode} request failed."); + throw new ServerException("{$mode} request failed" . (!is_null($msg) ? " ($msg)" : '.')); } /**