Skip to content

Commit 6eea2d1

Browse files
authored
MDEE-1064: store error logs together with main exception (#490)
1 parent 2c88c69 commit 6eea2d1

File tree

32 files changed

+231
-96
lines changed

32 files changed

+231
-96
lines changed

BundleProductDataExporter/Model/Provider/Product/BundleProductOptions.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,12 @@ public function get(array $values) : array
101101
$output[] = $this->formatBundleOptionsRow($row, $optionValues);
102102
}
103103
}
104-
} catch (Throwable $exception) {
105-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
106-
throw new UnableRetrieveData('Unable to retrieve bundle product options data');
104+
} catch (\Throwable $exception) {
105+
throw new UnableRetrieveData(
106+
sprintf('Unable to retrieve bundle product options data: %s', $exception->getMessage()),
107+
0,
108+
$exception
109+
);
107110
}
108111

109112
return $output;

CatalogDataExporter/Model/Provider/Categories.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,11 @@ public function execute(
108108
$dataProcessorCallback($this->get(\array_merge(...$output)));
109109
}
110110
} catch (\Throwable $exception) {
111-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
112-
throw new UnableRetrieveData('Unable to retrieve category data');
111+
throw new UnableRetrieveData(
112+
sprintf('Unable to retrieve category data: %s', $exception->getMessage()),
113+
0,
114+
$exception
115+
);
113116
}
114117
}
115118

CatalogDataExporter/Model/Provider/Category/AvailableSortBy.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ public function get(array $values) : array
6666
}
6767
}
6868
} catch (\Throwable $exception) {
69-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
70-
throw new UnableRetrieveData('Unable to retrieve category available sort by data');
69+
throw new UnableRetrieveData(
70+
sprintf('Unable to retrieve category available sort by data: %s', $exception->getMessage()),
71+
0,
72+
$exception
73+
);
7174
}
7275

7376
return $output;

CatalogDataExporter/Model/Provider/Category/Children.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ public function get(array $values) : array
7272
}
7373
}
7474
} catch (\Throwable $exception) {
75-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
76-
throw new UnableRetrieveData('Unable to retrieve category children');
75+
throw new UnableRetrieveData(
76+
sprintf('Unable to retrieve category children: %s', $exception->getMessage()),
77+
0,
78+
$exception
79+
);
7780
}
7881

7982
return $output;

CatalogDataExporter/Model/Provider/Category/DefaultSortBy.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ public function get(array $values) : array
8888
];
8989
}
9090
} catch (\Throwable $exception) {
91-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
92-
throw new UnableRetrieveData('Unable to retrieve category default sort by data');
91+
throw new UnableRetrieveData(
92+
sprintf('Unable to retrieve category default sort by data: %s', $exception->getMessage()),
93+
0,
94+
$exception
95+
);
9396
}
9497

9598
return $output;

CatalogDataExporter/Model/Provider/Category/Formatter/Output.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ function () use ($outputFormatter, $row, $attributeCode, $attributeKey) {
9595
}
9696
}
9797
} catch (\Throwable $exception) {
98-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
99-
throw new UnableRetrieveData('Unable to retrieve category formatted attribute data');
98+
throw new UnableRetrieveData(
99+
sprintf('Unable to retrieve category formatted attribute data: %s', $exception->getMessage()),
100+
0,
101+
$exception
102+
);
100103
}
101104

102105
return $row;

CatalogDataExporter/Model/Provider/Category/Image.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,11 @@ public function get(array $values) : array
144144
];
145145
}
146146
} catch (\Throwable $exception) {
147-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
148-
throw new UnableRetrieveData('Unable to retrieve category image');
147+
throw new UnableRetrieveData(
148+
sprintf('Unable to retrieve category image: %s', $exception->getMessage()),
149+
0,
150+
$exception
151+
);
149152
} finally {
150153
$this->storeManager->setCurrentStore($actualStoreCode);
151154
}

CatalogDataExporter/Model/Provider/EavAttributes/EavAttributesProvider.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,11 @@ public function getEavAttributesData(array $entityIds, string $storeCode, array
106106
return $this->formatEavAttributesArray($data, $attributeCodes);
107107
}, $this->attributesDataConverter->convert($attributes));
108108
} catch (\Throwable $exception) {
109-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
110-
throw new UnableRetrieveData('Unable to retrieve category eav attributes');
109+
throw new UnableRetrieveData(
110+
sprintf('Unable to retrieve category eav attributes: %s', $exception->getMessage()),
111+
0,
112+
$exception
113+
);
111114
}
112115
}
113116

CatalogDataExporter/Model/Provider/Product/Attributes.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ public function get(array $values): array
110110
}
111111
}
112112
} catch (\Exception $exception) {
113-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
114-
throw new UnableRetrieveData('Unable to retrieve attributes data', 0, $exception);
113+
throw new UnableRetrieveData(
114+
sprintf('Unable to retrieve attributes data: %s', $exception->getMessage()),
115+
0,
116+
$exception
117+
);
115118
}
116119
return $output;
117120
}

CatalogDataExporter/Model/Provider/Product/CategoryData.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ public function get(array $values) : array
8484
$output[$key]['categoryData'] = $result;
8585
}
8686
}
87-
} catch (\Exception $exception) {
88-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
89-
throw new UnableRetrieveData('Unable to retrieve category data for products');
87+
} catch (\Throwable $exception) {
88+
throw new UnableRetrieveData(
89+
sprintf('Unable to retrieve category data for products: %s', $exception->getMessage()),
90+
0,
91+
$exception
92+
);
9093
}
9194
return $output;
9295
}

CatalogDataExporter/Model/Provider/Product/Formatter/ImageFormatter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ public function format(array $row) : array
9999
}
100100
}
101101
} catch (\Throwable $exception) {
102-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
103-
throw new UnableRetrieveData('Unable to retrieve product formatted image data');
102+
throw new UnableRetrieveData(
103+
sprintf('Unable to retrieve product formatted image data: %s', $exception->getMessage()),
104+
0,
105+
$exception
106+
);
104107
}
105108

106109
return $row;

CatalogDataExporter/Model/Provider/Product/Links.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ public function get(array $values) : array
101101
}
102102
}
103103
} catch (\Throwable $exception) {
104-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
105-
throw new UnableRetrieveData('Unable to retrieve product links');
104+
throw new UnableRetrieveData(
105+
sprintf('Unable to retrieve product links: %s', $exception->getMessage()),
106+
0,
107+
$exception
108+
);
106109
}
107110

108111
return $output;

CatalogDataExporter/Model/Provider/Product/MediaGallery.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,11 @@ public function get(array $values) : array
122122
}
123123
}
124124
} catch (\Throwable $exception) {
125-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
126-
throw new UnableRetrieveData('Unable to retrieve product media gallery');
125+
throw new UnableRetrieveData(
126+
sprintf('Unable to retrieve product media gallery: %s', $exception->getMessage()),
127+
0,
128+
$exception
129+
);
127130
}
128131

129132
return $output;

CatalogDataExporter/Model/Provider/Product/ProductOptions/GroupedProductOptions.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,11 @@ public function get(array $values) : array
9797
}
9898
}
9999
} catch (\Throwable $exception) {
100-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
101-
throw new UnableRetrieveData('Unable to retrieve product links');
100+
throw new UnableRetrieveData(
101+
sprintf('Unable to retrieve product links: %s', $exception->getMessage()),
102+
0,
103+
$exception
104+
);
102105
}
103106

104107
return $output;

CatalogDataExporter/Model/Provider/Product/Samples.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,21 @@ class Samples
4343
*/
4444
private $sampleUrlProvider;
4545

46-
/**
47-
* @var LoggerInterface
48-
*/
49-
private $logger;
50-
5146
/**
5247
* @param ResourceConnection $resourceConnection
5348
* @param ProductSamplesQuery $productSamplesQuery
5449
* @param SampleUrlProvider $sampleUrlProvider
55-
* @param LoggerInterface $logger
50+
* @param LoggerInterface|null $logger @deprecated
5651
*/
5752
public function __construct(
5853
ResourceConnection $resourceConnection,
5954
ProductSamplesQuery $productSamplesQuery,
6055
SampleUrlProvider $sampleUrlProvider,
61-
LoggerInterface $logger
56+
?LoggerInterface $logger = null
6257
) {
6358
$this->resourceConnection = $resourceConnection;
6459
$this->productSamplesQuery = $productSamplesQuery;
6560
$this->sampleUrlProvider = $sampleUrlProvider;
66-
$this->logger = $logger;
6761
}
6862

6963
/**
@@ -122,8 +116,11 @@ public function get(array $values): array
122116
}
123117
}
124118
} catch (\Throwable $exception) {
125-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
126-
throw new UnableRetrieveData('Unable to retrieve product samples data');
119+
throw new UnableRetrieveData(
120+
sprintf('Unable to retrieve product samples data: %s', $exception->getMessage()),
121+
0,
122+
$exception
123+
);
127124
}
128125

129126
return $output;

CatalogDataExporter/Model/Provider/Product/WeightUnit.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ public function get(array $values) : array
7676
];
7777
}
7878
}
79-
} catch (\Exception $exception) {
80-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
81-
throw new UnableRetrieveData('Unable to retrieve weight type data');
79+
} catch (\Throwable $exception) {
80+
throw new UnableRetrieveData(
81+
sprintf('Unable to retrieve weight type data: %s', $exception->getMessage()),
82+
0,
83+
$exception
84+
);
8285
}
8386
return $output;
8487
}

CatalogDataExporter/Model/Provider/ProductAttributeMetadata/AttributeOptions.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,12 @@ public function get(array $values) : array
8585
}
8686
}
8787
}
88-
} catch (\Exception $e) {
89-
$this->logger->error('Unable to retrieve attribute options data. Error: ' . $e->getMessage(), ['exception' => $e]);
90-
throw new UnableRetrieveData('Unable to retrieve attribute options data. Error: ' . $e->getMessage(), 0, $e);
88+
} catch (\Exception $exception) {
89+
throw new UnableRetrieveData(
90+
sprintf('Unable to retrieve attribute options data: %s', $exception->getMessage()),
91+
0,
92+
$exception
93+
);
9194
}
9295
return $output;
9396
}

CatalogDataExporter/Model/Provider/ProductMetadata.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,12 @@ public function execute(
130130
while ($row = $cursor->fetch()) {
131131
$output[] = $this->format($row);
132132
}
133-
} catch (\Exception $exception) {
134-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
135-
throw new UnableRetrieveData('Unable to retrieve product data');
133+
} catch (\Throwable $exception) {
134+
throw new UnableRetrieveData(
135+
sprintf('Unable to retrieve product data: %s', $exception->getMessage()),
136+
0,
137+
$exception
138+
);
136139
}
137140

138141
$dataProcessorCallback($this->get($output));

CatalogInventoryDataExporter/Model/Plugin/Buyable.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ public function afterGet(ProductBuyable $subject, array $result)
6868
}
6969
}
7070
} catch (\Exception $exception) {
71-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
72-
throw new UnableRetrieveData('Unable to retrieve stock data');
71+
throw new UnableRetrieveData(
72+
sprintf('Unable to retrieve "buyable" field: %s', $exception->getMessage()),
73+
0,
74+
$exception
75+
);
7376
}
7477
return $result;
7578
}

CatalogInventoryDataExporter/Model/Provider/Product/InStock.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ public function get(array $values) : array
5555
$output[] = $stockItem;
5656
}
5757
} catch (\Exception $exception) {
58-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
59-
throw new UnableRetrieveData('Unable to retrieve stock data');
58+
throw new UnableRetrieveData(
59+
sprintf('Unable to retrieve InStock field data: %s', $exception->getMessage()),
60+
0,
61+
$exception
62+
);
6063
}
6164
return $output;
6265
}

CatalogInventoryDataExporter/Model/Provider/Product/LowStock.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ public function get(array $values) : array
114114
$output[] = $this->format($row, $thresholds);
115115
}
116116
} catch (\Exception $exception) {
117-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
118-
throw new UnableRetrieveData('Unable to retrieve stock data');
117+
throw new UnableRetrieveData(
118+
sprintf('Unable to retrieve LowStock field data: %s', $exception->getMessage()),
119+
0,
120+
$exception
121+
);
119122
}
120123
return $output;
121124
}

CatalogUrlRewriteDataExporter/Model/Provider/Product/UrlRewrites.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,12 @@ public function get(array $values): array
113113
$output[] = $this->format($urlRewrite, $storeViewCode);
114114
}
115115
}
116-
} catch (\Exception $exception) {
117-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
118-
throw new UnableRetrieveData('Unable to retrieve url rewrites data');
116+
} catch (\Throwable $exception) {
117+
throw new UnableRetrieveData(
118+
sprintf('Unable to retrieve url rewrites data: %s', $exception->getMessage()),
119+
0,
120+
$exception
121+
);
119122
}
120123

121124
return $output;

CatalogUrlRewriteDataExporter/Model/Provider/Product/Urls.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,12 @@ public function get(array $values) : array
110110
foreach ($output as &$product) {
111111
$product['url'] = $baseUrls[$product['storeViewCode']] . $product['url'];
112112
}
113-
} catch (\Exception $exception) {
114-
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
115-
throw new UnableRetrieveData('Unable to retrieve product URL data');
113+
} catch (\Throwable $exception) {
114+
throw new UnableRetrieveData(
115+
sprintf('Unable to retrieve product URL data: %s', $exception->getMessage()),
116+
0,
117+
$exception
118+
);
116119
}
117120
return $output;
118121
}

0 commit comments

Comments
 (0)