diff --git a/src/Skobkin/Bundle/PointToolsBundle/Service/Exceptions/ApiException.php b/src/Skobkin/Bundle/PointToolsBundle/Service/Exceptions/ApiException.php new file mode 100644 index 0000000..0eb8fd5 --- /dev/null +++ b/src/Skobkin/Bundle/PointToolsBundle/Service/Exceptions/ApiException.php @@ -0,0 +1,9 @@ +setId((int) $userData['id']); $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 @@ -146,12 +153,16 @@ class UserApi extends AbstractApi $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; } } - $this->em->flush(); - return $resultUsers; }