Announcement Announcement Module
No announcement yet.
Trapping parse errors in the validator? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trapping parse errors in the validator?

    I have a CustomDateEditor registered via initBinder(), but what I can't work out (although I'm sure it must be obvious and I'm just having a stupidity day) is how, within my validator, I trap any exceptions the CustomDateEditor might throw in its attempts to parse the input. For example, when I submit a form containing an invalid date, this is what ends up in my errors object for display on the form the user ends back at:

    'Failed to convert property value of type [java.lang.String] to required type [java.sql.Date] for property 'betDate'; nested exception is java.lang.IllegalArgumentException: Could not parse date: Unparseable date: "29/01/tt"'

    Obviously what I want is to trap this error and display a more useful message but I must have missed how I do this.

  • #2
    You can create messages for the conversion exceptions such as:{0} must be a date.

    There's some good discussion on this here:

    Also, the javadocs...



    • #3
      Great, that answers my question nicely! Thanks.