Verified Commit 6acd4fdd authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3202665 by danflanagan8, Ratan Priya, rupertj, longwave, smustgrave,...

Issue #3202665 by danflanagan8, Ratan Priya, rupertj, longwave, smustgrave, thursday_bw: "A(n) object was thrown while attempting to stub." Hard to debug migration message

(cherry picked from commit 2e76fda4)
parent 5d0e6445
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -263,7 +263,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
        throw $e;
      }
      catch (\Exception $e) {
        throw new MigrateException(sprintf('A(n) %s was thrown while attempting to stub.', gettype($e)), $e->getCode(), $e);
        throw new MigrateException(sprintf('%s was thrown while attempting to stub: %s', get_class($e), $e->getMessage()), $e->getCode(), $e);
      }
    }
    if ($destination_ids) {
+7 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\Tests\migrate\Unit\process;

use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateSkipProcessException;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\migrate\process\MigrationLookup;
@@ -60,6 +61,12 @@ public function testTransformWithStubbing() {
    $migration = MigrationLookup::create($this->prepareContainer(), $configuration, '', [], $migration_plugin->reveal());
    $result = $migration->transform(1, $this->migrateExecutable, $this->row, '');
    $this->assertEquals(2, $result);

    $this->migrateStub->createStub('destination_migration', [1], [], FALSE)->willThrow(new \Exception('Oh noes!'));
    $migration = MigrationLookup::create($this->prepareContainer(), $configuration, '', [], $migration_plugin->reveal());
    $this->expectException(MigrateException::class);
    $this->expectExceptionMessage('Exception was thrown while attempting to stub: Oh noes!');
    $migration->transform(1, $this->migrateExecutable, $this->row, '');
  }

  /**