1
0
mirror of https://github.com/flarum/core.git synced 2025-07-21 08:41:17 +02:00

Throw an exception if discussion not found

closes flarum/core#208
This commit is contained in:
Toby Zerner
2015-08-06 13:59:09 +09:30
parent b42cbc761a
commit ccbfb0754d
2 changed files with 14 additions and 1 deletions

View File

@@ -13,4 +13,9 @@ class Response
{ {
return json_decode($this->response->getBody()); return json_decode($this->response->getBody());
} }
public function getStatusCode()
{
return $this->response->getStatusCode();
}
} }

View File

@@ -1,6 +1,7 @@
<?php namespace Flarum\Forum\Actions; <?php namespace Flarum\Forum\Actions;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
use Flarum\Http\RouteNotFoundException;
class DiscussionAction extends ClientAction class DiscussionAction extends ClientAction
{ {
@@ -70,6 +71,13 @@ class DiscussionAction extends ClientAction
$actor = app('flarum.actor'); $actor = app('flarum.actor');
$action = 'Flarum\Api\Actions\Discussions\ShowAction'; $action = 'Flarum\Api\Actions\Discussions\ShowAction';
return $this->apiClient->send($actor, $action, $params)->getBody(); $response = $this->apiClient->send($actor, $action, $params);
$statusCode = $response->getStatusCode();
if ($statusCode === 404) {
throw new RouteNotFoundException;
}
return $response->getBody();
} }
} }