Skip to content
Snippets Groups Projects
Unverified Commit 2758e602 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3004718 by quietone, Jo Fitzgerald, edysmp: Better MigrateException...

Issue #3004718 by quietone, Jo Fitzgerald, edysmp: Better MigrateException message in the format_date process plugin
parent 7dcda1f6
No related branches found
No related tags found
No related merge requests found
......@@ -134,10 +134,10 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
$transformed = DateTimePlus::createFromFormat($fromFormat, $value, $from_timezone, $settings)->format($toFormat, ['timezone' => $to_timezone]);
}
catch (\InvalidArgumentException $e) {
throw new MigrateException(sprintf('Format date plugin could not transform "%s" using the format "%s". Error: %s', $value, $fromFormat, $e->getMessage()), $e->getCode(), $e);
throw new MigrateException(sprintf("Format date plugin could not transform '%s' using the format '%s' for destination '%s'. Error: %s", $value, $fromFormat, $destination_property, $e->getMessage()), $e->getCode(), $e);
}
catch (\UnexpectedValueException $e) {
throw new MigrateException(sprintf('Format date plugin could not transform "%s" using the format "%s" for destination "%s". Error: %s', $value, $fromFormat, $destination_property, $e->getMessage()), $e->getCode(), $e);
throw new MigrateException(sprintf("Format date plugin could not transform '%s' using the format '%s' for destination '%s'. Error: %s", $value, $fromFormat, $destination_property, $e->getMessage()), $e->getCode(), $e);
}
return $transformed;
......
......@@ -51,7 +51,7 @@ public function testMigrateExceptionBadFormat() {
'to_format' => 'Y-m-d',
];
$this->setExpectedException(MigrateException::class, 'Format date plugin could not transform "January 5, 1955" using the format "m/d/Y". Error: The date cannot be created from a format.');
$this->setExpectedException(MigrateException::class, "Format date plugin could not transform 'January 5, 1955' using the format 'm/d/Y' for destination 'field_date'. Error: The date cannot be created from a format.");
$this->plugin = new FormatDate($configuration, 'test_format_date', []);
$this->plugin->transform('January 5, 1955', $this->migrateExecutable, $this->row, 'field_date');
}
......@@ -65,7 +65,7 @@ public function testMigrateExceptionUnexpectedValue() {
'to_format' => 'Y-m-d',
];
$this->setExpectedException(MigrateException::class, 'Format date plugin could not transform "01/05/55" using the format "m/d/Y" for destination "field_date". Error: The created date does not match the input value.');
$this->setExpectedException(MigrateException::class, "Format date plugin could not transform '01/05/55' using the format 'm/d/Y' for destination 'field_date'. Error: The created date does not match the input value.");
$this->plugin = new FormatDate($configuration, 'test_format_date', []);
$this->plugin->transform('01/05/55', $this->migrateExecutable, $this->row, 'field_date');
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment