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

merge-requests/2817/merge
Alex Pott 2022-10-04 10:33:27 +01:00
parent eaa010f97a
commit 2e76fda4ff
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
2 changed files with 8 additions and 1 deletions

View File

@ -263,7 +263,7 @@ class MigrationLookup extends ProcessPluginBase implements ContainerFactoryPlugi
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) {

View File

@ -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 @@ class MigrationLookupTest extends MigrationLookupTestCase {
$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, '');
}
/**