Skip to content

Commit

Permalink
DX: Mention table and column-name in unqiue error message (#110)
Browse files Browse the repository at this point in the history
Display table and column name when an exception is thrown by a converter
  • Loading branch information
staabm authored Feb 20, 2024
1 parent e14618b commit 3700467
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Dumper/Listener/DataConverterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Smile\GdprDump\Dumper\Listener;

use Exception;
use RuntimeException;
use Smile\GdprDump\Converter\ConditionBuilder;
use Smile\GdprDump\Converter\ConverterBuilder;
use Smile\GdprDump\Converter\ConverterInterface;
Expand Down Expand Up @@ -71,8 +73,16 @@ private function getHook(): callable
}

// Convert the value
$row[$column] = $converter->convert($row[$column], $context);
$context['processed_data'][$column] = $row[$column];
try {
$row[$column] = $converter->convert($row[$column], $context);
$context['processed_data'][$column] = $row[$column];
} catch (Exception $exception) {
throw new RuntimeException(
$table . '.' . $column . ': ' . $exception->getMessage(),
$exception->getCode(),
$exception
);
}
}

return $row;
Expand Down

0 comments on commit 3700467

Please sign in to comment.