PostFactory exception fix.

This commit is contained in:
Alexey Skobkin 2017-01-09 21:43:41 +03:00
parent bdbcf14a15
commit fbea7ffe4e
4 changed files with 23 additions and 8 deletions

View file

@ -0,0 +1,8 @@
<?php
namespace Skobkin\Bundle\PointToolsBundle\Exception\Factory\Blog;
class FactoryException extends \Exception
{
}

View file

@ -0,0 +1,8 @@
<?php
namespace Skobkin\Bundle\PointToolsBundle\Exception\Factory\Blog;
class InvalidDataException extends FactoryException
{
}

View file

@ -1,12 +1,11 @@
<?php
namespace Skobkin\Bundle\PointToolsBundle\Service\Exceptions\Factory\Blogs;
namespace Skobkin\Bundle\PointToolsBundle\Exception\Factory\Blog;
use Exception;
use Skobkin\Bundle\PointToolsBundle\DTO\Api\Crawler\Post;
class InvalidPostDataException extends \Exception
class InvalidPostDataException extends InvalidDataException
{
/**
* @var Post
@ -23,7 +22,7 @@ class InvalidPostDataException extends \Exception
/**
* @return Post
*/
public function getPost()
public function getPost(): Post
{
return $this->post;
}

View file

@ -9,8 +9,9 @@ use Skobkin\Bundle\PointToolsBundle\DTO\Api\Crawler\MetaPost;
use Skobkin\Bundle\PointToolsBundle\DTO\Api\Crawler\PostsPage;
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post;
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\PostTag;
use Skobkin\Bundle\PointToolsBundle\Exception\Factory\Blog\InvalidDataException;
use Skobkin\Bundle\PointToolsBundle\Service\Exceptions\ApiException;
use Skobkin\Bundle\PointToolsBundle\Service\Exceptions\Factory\Blogs\InvalidPostDataException;
use Skobkin\Bundle\PointToolsBundle\Exception\Factory\Blog\InvalidPostDataException;
use Skobkin\Bundle\PointToolsBundle\Service\Exceptions\InvalidResponseException;
use Skobkin\Bundle\PointToolsBundle\Service\Factory\UserFactory;
@ -115,13 +116,12 @@ class PostFactory
* @return Post
*
* @throws ApiException
* @throws InvalidPostDataException
* @throws InvalidDataException
*/
private function createFromDTO(MetaPost $postData): Post
{
if (!$this->validateMetaPost($postData)) {
// FIXME
throw new InvalidPostDataException('Invalid post data', $postData);
throw new InvalidDataException('Invalid post data');
}
if (!$postData->getPost()->getAuthor()->getId()) {