From 2ed23a082cfabf4d61f0ed313158f33aff14924f Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Mon, 5 Jan 2026 14:59:56 -0400 Subject: [PATCH 1/2] More specific logging for failed enqueues. --- src/MigrateBatchExecutable.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/MigrateBatchExecutable.php b/src/MigrateBatchExecutable.php index ec3d48d..11222ec 100644 --- a/src/MigrateBatchExecutable.php +++ b/src/MigrateBatchExecutable.php @@ -159,9 +159,11 @@ public function prepareBatch() { 'finished' => [$this, 'finishBatch'], ]; } - else { - throw new \Exception('Migration failed.'); + + if ($this->enqueueException) { + throw new \Exception('Migration failed. Wrapped exception: ' . $this->enqueueException->getMessage(), previous: $this->enqueueException); } + throw new \Exception('Migration failed.'); } /** @@ -180,6 +182,13 @@ public function teardownMigration() { $this->migration->setStatus(MigrationInterface::STATUS_IDLE); } + /** + * Stash any exception encountered during enqueueing, so it can be reported. + * + * @var \Exception|null + */ + protected ?\Exception $enqueueException = NULL; + /** * Populate the target queue with the rows of the given migration. * @@ -218,6 +227,7 @@ protected function enqueue() { ), 'error' ); + $this->enqueueException = $e; return MigrationInterface::RESULT_FAILED; } @@ -232,6 +242,7 @@ protected function enqueue() { $this->message->display( $this->t('Migration failed with source plugin exception: @e', ['@e' => $e]), 'error'); $this->migration->setStatus(MigrationInterface::STATUS_IDLE); + $this->enqueueException = $e; return MigrationInterface::RESULT_FAILED; } From 243593a0eb2d8703a826fa4053262d8dfd40f1cf Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Thu, 15 Jan 2026 16:25:11 -0400 Subject: [PATCH 2/2] Add additional context to the exception message. Is rather more important during drush invocations. Might be somewhat spammy with the migration ID in the GUI? --- src/MigrateBatchExecutable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MigrateBatchExecutable.php b/src/MigrateBatchExecutable.php index 11222ec..4f0310a 100644 --- a/src/MigrateBatchExecutable.php +++ b/src/MigrateBatchExecutable.php @@ -161,9 +161,9 @@ public function prepareBatch() { } if ($this->enqueueException) { - throw new \Exception('Migration failed. Wrapped exception: ' . $this->enqueueException->getMessage(), previous: $this->enqueueException); + throw new \Exception("Migration ({$this->migration->id()}) failed. Wrapped exception: {$this->enqueueException->getMessage()}", previous: $this->enqueueException); } - throw new \Exception('Migration failed.'); + throw new \Exception("Migration ({$this->migration->id()}) failed."); } /**