This question about Developing extensions (plugins skins etc.): Answered

How Should a Plugin Indicate Incorrect Parameter Values

When developing plugins, how should a plugin indicate to a end-user that something is incorrect about the supplied parameters. For example, if a macro requires a certain parameter and it is not supplied by the user, what should the plugin's code do when in the tag handler code?

I've noticed from reading the source that a common action is to simply return nothing unless a parameter is defined. This causes the macro code to be rendered as is when the page is viewed. Is this the best practise? Is there ways of warning the user of the specific reason why their macro wasn't rendered?

From a newbie at plugin development

-- LeeRyman - 08 May 2009

Yes, the 'TmWiki' tradition was to return an empty string on most errors - but I think we'll be changing that in future - I've been toying with an 'error status' report for topics, and IF does also report errors in the parsing of the predicate section.

mostly it depends on your needs and what is appropriate for your plugin at this time - hopefully within the next year we can re-do the macro parameter work so that marcro registration also contains the parameter spec and some checking and reporting.

-- SvenDowideit - 08 May 2009

Error detection reporting is a ticklish subject. When I'm writing plugins myself, I use a sort of "defcon" approach to classify different "error events".

At some point I plan to expose the Foswiki::Logger interface to plugins to increase the flexibility of error reporting, but until then the above defcon approach should help.

-- CrawfordCurrie - 08 May 2009

Thanks for the answers Sven and Crawford. It does seem like most user macro stuffups will belong in the realm of Defcon 3. Perhaps there could be an API for returning the suggested foswikiAlert messages in an abstracted manner. I'm also dealing with relative wiki-newbies, so some sort of appropriately skinned error message when a parameter is missing or incorrect would be nice. I will have a look at the IF macro's code too. It is funny, but when ever I'm designing software it is always how to handle errors that seems to take the most time and thought. There is often a fine line between application error where the user stuffs-up, and system error when the application stuffs-up, and reporting and dealing with them appropriately can be challenging.

Could I suggest a new question Subject related to development of foswiki and/or extensions? Is this the appropriate place to ask such questions as above? Thanks again.

-- LeeRyman - 10 May 2009

Yes, it's a good place to ask such questions. There is some resistance among some of the community to acknowledging the role/existence of developers, but I'm sure we can sneak in a new Subject - and maybe even a new FAQ - under the radar smile

-- CrawfordCurrie - 10 May 2009
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons LicenseGet Foswiki at sourceforge.net. Fast, secure and Free Open Source software downloads