From 0f5347c1d3c8707a796fa91c3d6ebfb2baec841f Mon Sep 17 00:00:00 2001 From: Yegor Shytikov Date: Wed, 9 Apr 2025 17:51:54 -0700 Subject: [PATCH] improve error handling SchemaBuilder Extending error context : Previous: ```Warning: Undefined array key "type" in /var/www/html/magento/vendor/magento/framework/Setup/Declaration/Schema/Db/SchemaBuilder.php on line 91``` Now: ```Warning: Undefined array key "type" in /var/www/html/magento/vendor/magento/framework/Setup/Declaration/Schema/Db/SchemaBuilder.php on line 91 Error processing table catalog_eav_attribute column is_used_in_autocomplete``` Help undersend the issue without heavy debugging! --- .../Declaration/Schema/Db/SchemaBuilder.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/SchemaBuilder.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/SchemaBuilder.php index 3395745ca4590..ba44a86045dd7 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/SchemaBuilder.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/SchemaBuilder.php @@ -87,8 +87,22 @@ public function build(Schema $schema) if (isset($data['table'])) { foreach ($data['table'] as $keyTable => $tableColumns) { foreach ($tableColumns['column'] as $keyColumn => $columnData) { - if ($columnData['type'] == 'json') { - $tablesWithJsonTypeField[$keyTable] = $keyColumn; + try { + if ($columnData['type'] == 'json') { + $tablesWithJsonTypeField[$keyTable] = $keyColumn; + } + } catch (\Throwable $e) { + // Create a new exception with extended context message + $errorMessage = sprintf( + "%s\nError processing table %s column %s", + $e->getMessage(), + $keyTable, + $keyColumn + ); + + // Throw a new exception with the extended message + // This preserves the original error but adds our context + throw new \Exception($errorMessage, $e->getCode(), $e); } } }