Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
While working on #3004718: Better MigrateException message in the format_date process plugin I found that the (equally bad) UnexpectedValueException message was not being tested.
Proposed resolution
Add a test for throwing an UnexpectedValueException.
Remaining tasks
Write patch.
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#6 | 3011069-6.patch | 2.17 KB | jofitz |
#6 | interdiff-3011069-2-6.txt | 2.1 KB | jofitz |
#2 | 3011069-2.patch | 2.15 KB | jofitz |
Comments
Comment #2
jofitz CreditAttribution: jofitz at jofitz commentedAdded test (and improved exception message in line with #3004718: Better MigrateException message in the format_date process plugin.
Comment #3
quietone CreditAttribution: quietone as a volunteer commented@Jo Fitzgerald, good catch.
Let's add the destination property to this and then get this in. There is a suggestion in #2959444-Comment #10 to add a method on ProcessPluginBase to help with the error messages. But in the meantime just adding the destination property is helpful.
Comment #4
quietone CreditAttribution: quietone as a volunteer commentedAh, it was right in front of me, the destination property is there!
Comment #5
quietone CreditAttribution: quietone as a volunteer commentedNothing like a toddler to make me lose what I was trying to do here. I think the message needs tweaking. Saying that the plugin could not transform the destination property isn't quite right since the source value is transformed not the destination. Looking at the process plugins in the migrate for ideas there is only StaicMap that uses the destination_property in the error message.
throw new MigrateSkipRowException(sprintf("No static mapping found for '%s' and no default value provided for destination '%s'.", Variable::export($value), $destination_property));
Using that as a guide how about 'Format date plugin could not transform value "%s" using the format "%s" for destination '%s'. Error: %s' ?
What do you think?
Comment #6
jofitz CreditAttribution: jofitz at jofitz commentedCorrected the exception message.
Comment #7
quietone CreditAttribution: quietone as a volunteer commented@Jo Fitzgerald, excellent, thanks!
This adds a test for the exception message from FormatDate, which Jo Fitzgerald spotted and fixed, and the message includes more context which is always useful. There are plans to add even more context to the process plugin exception messages but that is still in the early stages and should not hold this up.
Comment #8
catchCommitted 148b87f and pushed to 8.7.x. Thanks!