Skip to content

Commit

Permalink
Added better error handling and reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirk Scholten committed Jun 10, 2020
1 parent 681bb64 commit 87959af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ public function execute(AMQPMessage $message)
$returnValue = $this->mappedBulkSaver->flush();
}
} catch (\Throwable $e) {
$this->logger->error('SafeSalesforceSaver - message: ' . $e->getMessage() . ' - body: ' . $message->body);
throw $e;
$this->logger->error('SafeSalesforceSaver - message: ' . $e->getMessage() . ' - body: ' . $message->body . ' - end of SafeSalesforceSaver message');

if (strpos($e->getMessage(), 'unable to obtain exclusive access') !== false) {
throw $e;
}
$returnValue = serialize($e->getMessage());
}

return $returnValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Comsave\SafeSalesforceSaverBundle\Services;

use Comsave\SafeSalesforceSaverBundle\Exception\SaveException;
use Comsave\SafeSalesforceSaverBundle\Producer\AsyncSfSaverProducer;
use Comsave\SafeSalesforceSaverBundle\Producer\RpcSfSaverClient;
use Traversable;
Expand Down Expand Up @@ -48,8 +47,8 @@ public function aSyncSave($models): void
public function save($models): void
{
$rawResult = $this->rpcSaver->call(serialize($this->turnModelsIntoArray($models)));

if (@$result = unserialize($rawResult)) {
@$result = unserialize($rawResult);
if ($result !== false && gettype($result) != 'string') {

if (is_countable($models) && count($models) != 1) {
$iterator = 0;
Expand All @@ -67,8 +66,6 @@ public function save($models): void
$models->setId($result->getId());
}
}
} else {
throw new SaveException($rawResult);
}
}

Expand Down

0 comments on commit 87959af

Please sign in to comment.