in reply to A Refactoring We Will Go

Params::Check looks like it is the right module for use here, and I managed to get it working, somewhat (with a slight syntax poke/help from jeffa). Now the problem is that I need to generate a custom error message when the params are incorrect (instead of the generic die "Could not parse arguments\n"; message).

For example, if I accept a date range in 'blort' above ($conf{'template'}->{'blort'}) of the format YYYY-MM-DD, and the value supplied by the template's value in that key is DD-MM-YYYY, I would like to die with an error specific to that key, and then return a list of the proper syntax, such as:

"Date format incorrect, please supply the date in the format YYYY-MM-DD for proper parsing."

How would I go about doing that? I see that in Params::Check, I can run another sub inside the accept() object to pass the args, and validate that way, but now I'm back to doing ~40 different calls to that check, which is back to where I started.

Replies are listed 'Best First'.
Re^2: A Refactoring We Will Go (patch)
by tye (Sage) on Jul 01, 2003 at 15:36 UTC

    I'd patch the module to support a custom message per parameter.

                    - tye