API exceptions.
This commit is contained in:
parent
de234f1290
commit
f351fc22ff
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Skobkin\Bundle\PointToolsBundle\Service\Exceptions;
|
||||||
|
|
||||||
|
|
||||||
|
class ApiException extends \Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Skobkin\Bundle\PointToolsBundle\Service\Exceptions;
|
||||||
|
|
||||||
|
|
||||||
|
class SubscriptionManagerException extends \Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Guzzle\Service\Client;
|
use Guzzle\Service\Client;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Entity\User;
|
use Skobkin\Bundle\PointToolsBundle\Entity\User;
|
||||||
|
use Skobkin\Bundle\PointToolsBundle\Service\Exceptions\ApiException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic Point.im user API functions from /api/user/*
|
* Basic Point.im user API functions from /api/user/*
|
||||||
|
@ -136,6 +137,12 @@ class UserApi extends AbstractApi
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$user->setId((int) $userData['id']);
|
$user->setId((int) $userData['id']);
|
||||||
$this->em->persist($user);
|
$this->em->persist($user);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->em->flush();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new ApiException(sprintf('Error while flushing new user [%d] %s', $user->getId(), $user->getLogin()), 0, $e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updating data
|
// Updating data
|
||||||
|
@ -146,12 +153,16 @@ class UserApi extends AbstractApi
|
||||||
$user->setName($userData['name']);
|
$user->setName($userData['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->em->flush();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new ApiException(sprintf('Error while flushing changes for [%d] %s', $user->getId(), $user->getLogin()), 0, $e);
|
||||||
|
}
|
||||||
|
|
||||||
$resultUsers[] = $user;
|
$resultUsers[] = $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->em->flush();
|
|
||||||
|
|
||||||
return $resultUsers;
|
return $resultUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue