Skip to content

Commit

Permalink
Fix product enrich job - Add error message
Browse files Browse the repository at this point in the history
  • Loading branch information
jmleroux committed May 16, 2017
1 parent ff36958 commit 6400ed0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Xml/XmlProductDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Pim\Bundle\IcecatConnectorBundle\Xml;

use Akeneo\Component\StorageUtils\Detacher\ObjectDetacherInterface;
use Oro\Bundle\ConfigBundle\Config\ConfigManager;
use Pim\Bundle\CatalogBundle\Entity\AttributeOption;
use Pim\Bundle\ExtendedMeasureBundle\Repository\MeasureRepositoryInterface;
Expand All @@ -11,7 +10,6 @@
use Pim\Component\Catalog\AttributeTypes;
use Pim\Component\Catalog\Model\AttributeInterface;
use Pim\Component\Catalog\Repository\AttributeRepositoryInterface;
use Pim\Component\Catalog\Updater\Remover\RemoverInterface;
use Symfony\Component\Serializer\Encoder\DecoderInterface;

/**
Expand Down Expand Up @@ -73,6 +71,7 @@ public function __construct(
public function decode($xmlString, $format, array $context = [])
{
$standardItem = [];
$icecatProduct = null;

try {
$simpleXmlNode = simplexml_load_string($xmlString);
Expand Down Expand Up @@ -152,6 +151,9 @@ public function decode($xmlString, $format, array $context = [])
} catch (MapperException $e) {
throw $e;
} catch (\Exception $e) {
if ($icecatProduct instanceof \SimpleXMLElement && (string) $icecatProduct['Code'] === '-1') {
throw new XmlDecodeException($icecatProduct['ErrorMessage'], 0, $e);
}
throw new XmlDecodeException(sprintf('XML decode error for string %s', $xmlString), 0, $e);
}

Expand Down

0 comments on commit 6400ed0

Please sign in to comment.