diff options
Diffstat (limited to 'Digitigrade/Model/Instance.php')
| -rw-r--r-- | Digitigrade/Model/Instance.php | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Digitigrade/Model/Instance.php b/Digitigrade/Model/Instance.php index b3a179f..2b07b9a 100644 --- a/Digitigrade/Model/Instance.php +++ b/Digitigrade/Model/Instance.php @@ -1,6 +1,7 @@ <?php namespace Digitigrade\Model; +use Digitigrade\Exception\EndpointMissingException; use Digitigrade\GlobalConfig; use Digitigrade\Job\RefreshOutboundAuthToken; @@ -88,7 +89,7 @@ class Instance extends FetchableModel { public function beginOutboundAuth() { $authEndpoint = $this->endpoints->auth; if (!isset($authEndpoint)) { - throw new \RuntimeException("can't authenticate with $this->domain because it doesn't have an auth endpoint"); + throw new EndpointMissingException($this, 'auth'); } file_get_contents($authEndpoint . '?phase=dialback&target=' . urlencode(path_to_uri('/auth/dialback'))); } @@ -96,7 +97,7 @@ class Instance extends FetchableModel { public function requestOutboundAuthToken(string $secret) { $authEndpoint = $this->endpoints->auth; if (!isset($authEndpoint)) { - throw new \RuntimeException("can't authenticate with $this->domain because it doesn't have an auth endpoint"); + throw new EndpointMissingException($this, 'auth'); } $response = file_get_contents($authEndpoint . '?phase=token&secret=' . urlencode($secret)); if ($response === false) { @@ -123,7 +124,7 @@ class Instance extends FetchableModel { public function refreshOutboundAuthToken() { $authEndpoint = $this->endpoints->auth; if (!isset($authEndpoint)) { - throw new \RuntimeException("can't authenticate with $this->domain because it doesn't have an auth endpoint"); + throw new EndpointMissingException($this, 'auth'); } if (!isset($this->auth->outboundToken)) { throw new \RuntimeException("can't refresh outbound token for $this->domain because i don't already have one"); @@ -147,7 +148,7 @@ class Instance extends FetchableModel { private function subscribeOrUnsubscribe(bool $isUnsubscribe): bool { if (!isset($this->endpoints->subscribe, $this->endpoints->unsubscribe)) { - throw new \RuntimeException("can't (un)subscribe to $this->domain because it doesn't have the right endpoints"); + throw new EndpointMissingException($this, 'subscribe'); } if (!isset($this->auth->outboundToken)) { throw new \RuntimeException("can't (un)subscribe to $this->domain because i don't have an outbound token for it"); @@ -189,7 +190,7 @@ class Instance extends FetchableModel { public function pushObject(PushableModel $obj) { if (!isset($this->endpoints->push)) { - throw new \RuntimeException("can't push to $this->domain because it doesn't have a push endpoint"); + throw new EndpointMissingException($this, 'push'); } if (!isset($this->auth->outboundToken)) { throw new \RuntimeException("can't push to $this->domain because i don't have an outbound token for it"); |
