in reply to Re: EyeBall stumps BodBall
in thread EyeBall stumps BodBall (Error Handling)
G'day Bod,
Here's a few things that I do which you may find useful (possibly in code outside the Business::Stripe:: namespace). In general, these are intended to promote consistency and reduce coding effort.
Have a small number of routines to output messages (e.g. print_error(), print_warning() and so on). These accept a format for the message along with a variable number of arguments. Here's a very rough, off-the-top-of-my-head example:
sub print_error { my ($fmt, @args) = @_; die 'ERROR: ', sprintf $fmt, @args; }
Define each format once only. This could be globally as a constant, specific to a subroutine as a state variable, or using some other method; you may even use a combination of these. Here's some arbitrary examples of formats:
'Start date (%s) cannot be after end date (%s)' 'Postcode (%s) contains invalid characters' 'ID is a required field'
You can paste these formats directly into the DIAGNOSTICS (or equivalent) section of your POD. See perldiag for a multitude of examples of this type of documentation.
Where possible, I try to collect as many problem reports as possible into a single message. So, if the above three example formats were needed, the user would know to make changes to date, postcode and ID fields from a single piece of feedback, rather than being drip-fed one problem at a time.
How messages are presented will very much depend on the interface. With GUIs (web or other) I often find a small [i] button can provide information about what exactly is required in a field. A popup panel can list the problems and also contain the same [i] buttons for ease of reference.
— Ken
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: EyeBall stumps BodBall
by Bod (Parson) on Jul 23, 2023 at 21:13 UTC |