Updated Branches: refs/heads/master 7428323ac -> e1a0f045d
WICKET-4864 'format' not set in ConversionException Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/e1a0f045 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/e1a0f045 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/e1a0f045 Branch: refs/heads/master Commit: e1a0f045d6aff9fb171fd0bfd861c87c8be760dd Parents: 7428323 Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Thu Nov 15 10:35:54 2012 +0200 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Thu Nov 15 10:35:54 2012 +0200 ---------------------------------------------------------------------- .../org/apache/wicket/datetime/DateConverter.java | 19 +++++++++++++- 1 files changed, 17 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/e1a0f045/wicket-datetime/src/main/java/org/apache/wicket/datetime/DateConverter.java ---------------------------------------------------------------------- diff --git a/wicket-datetime/src/main/java/org/apache/wicket/datetime/DateConverter.java b/wicket-datetime/src/main/java/org/apache/wicket/datetime/DateConverter.java index 3aa95eb..1c752c6 100644 --- a/wicket-datetime/src/main/java/org/apache/wicket/datetime/DateConverter.java +++ b/wicket-datetime/src/main/java/org/apache/wicket/datetime/DateConverter.java @@ -98,7 +98,7 @@ public abstract class DateConverter implements IConverter<Date> } catch (RuntimeException e) { - throw new ConversionException(e); + throw newConversionException(e, locale); } // apply the server time zone to the parsed value if (zone != null) @@ -117,12 +117,27 @@ public abstract class DateConverter implements IConverter<Date> } catch (RuntimeException e) { - throw new ConversionException(e); + throw newConversionException(e, locale); } } } /** + * Creates a ConversionException and sets additional context information to it. + * + * @param cause + * - {@link RuntimeException} cause + * @param locale + * - {@link Locale} used to set 'format' variable with localized pattern + * @return {@link ConversionException} + */ + private ConversionException newConversionException(RuntimeException cause, Locale locale) + { + return new ConversionException(cause) + .setVariable("format", getDatePattern(locale)); + } + + /** * @see org.apache.wicket.util.convert.IConverter#convertToString(java.lang.Object, * java.util.Locale) */
