Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General improvements #60

Merged
merged 2 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/Import/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Jh\Import\Import;

use Countable;
use Exception;
use Jh\Import\Archiver\Factory as ArchiverFactory;
use Jh\Import\Config;
use Jh\Import\Locker\ImportLockedException;
Expand All @@ -16,6 +17,7 @@
use Jh\Import\Source\Source;
use Jh\Import\Specification\ImportSpecification;
use Jh\Import\Writer\Writer;
use Magento\Framework\Exception\AggregateExceptionInterface;

/**
* @author Aydin Hassan <aydin@wearejh.com>
Expand Down Expand Up @@ -142,13 +144,13 @@ public function process(Config $config): void

try {
$this->traverseSource($config, $report);
} catch (\Exception $e) {
} catch (Exception $e) {
$report->addError(sprintf('Could not read data from source. Error: "%s"', $e->getMessage()));
}

try {
$this->finish($config, $report);
} catch (\Exception $e) {
} catch (Exception $e) {
$report->addError(sprintf(
'An error occurred when performing post processing tasks (cleanup, indexing, etc) . Error: "%s"',
$e->getMessage()
Expand All @@ -158,7 +160,7 @@ public function process(Config $config): void
try {
$archiver = $this->archiverFactory->getArchiverForSource($this->source, $config);
$report->isSuccessful() ? $archiver->successful() : $archiver->failed();
} catch (\Exception $e) {
} catch (Exception $e) {
$report->addError(sprintf(
'An error occurred when archiving the import source . Error: "%s"',
$e->getMessage()
Expand Down Expand Up @@ -241,8 +243,12 @@ private function traverseSource(Config $config, Report $report): void

$this->processTransformers($record, $reportItem);
$this->writer->write($record, $reportItem);
} catch (\Exception $e) {
$reportItem->addError($e->getMessage());
} catch (AggregateExceptionInterface $aggregateException) {
foreach ($aggregateException->getErrors() as $exception) {
$reportItem->addError($exception->getMessage());
}
} catch (Exception $exception) {
$reportItem->addError($exception->getMessage());
}

$this->progress->advance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
</filterSelect>
</filters>
<paging name="listing_paging"/>
<exportButton name="export_button"/>
</listingToolbar>

<columns name="log_columns" class="Magento\Ui\Component\Listing\Columns">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<filterSearch name="fulltext"/>
<filters name="listing_filters"/>
<paging name="listing_paging"/>
<exportButton name="export_button"/>
</listingToolbar>

<columns name="log_columns" class="Magento\Ui\Component\Listing\Columns">
Expand Down