This wasn’t a vote but everybody who replied agreed (Marius, Thomas, Vincent, 
Sergiu, Edy wasn’t thrilled but was ok too ;)), so let’s do it!

I’ve now documented it at 

So please make sure you code your Script Services so that they throw exceptions 
now :)


> On 18 Jan 2016, at 11:03, vinc...@massol.net wrote:
> Hi devs,
> After a lot of thinking and experimentation (see the thread’s details), I 
> have found that this first proposal is not a good idea. I’m thus proposing to 
> replace it with the following best practice:
> * Let our script services generate exceptions
> * If the velocity scripts with to handle the exceptions, then they should use 
> the #try() directive. If they don’t want to, they don’t have to do anything 
> since the MacroTransformation or the template (contentvars.vm for example) 
> will catch it and display it to the user.
> More precisely I’m proposing that:
> * Existing Script APIs in Java should not be modified as that would break 
> backward compatibility. New signatures can be added and old one deprecated 
> and moved to the legacy modules. After new signatures have been introduced, 
> existing velocity scripts can be updated to use the new signatures and to use 
> the #try directive if needed.
> * New Script APIs must use the new best practices (if agreed :)), i.e. throw 
> Exceptions, and new velocity scripts must use the #try() directive if they 
> need to handle exceptions.
> Thanks
> -Vincent
> On 14 Jan 2016 at 17:51:04, vinc...@massol.net 
> (vinc...@massol.net(mailto:vinc...@massol.net)) wrote:
>> Hi devs,  
>> Right now our strategy is for script services and script APIs in general to 
>> catch exceptions, store them and offer a getLastError() method to get them 
>> (see 
>> http://extensions.xwiki.org/xwiki/bin/view/Extension/Script+Module#HBestPractices)
>> However it would be much nicer to:  
>> * Let our script services generate exceptions
>> * Offer a velocity script service to get the last exception raised by a java 
>> call from velocity
>> * Implement this uberspector to catch the exceptions and to set them in the 
>> execution context
>> That should be quite easy to implement IMO.  
>> WDYT?  
>> Thanks  
>> -Vincent
>> PS: This is http://jira.xwiki.org/browse/XWIKI-2374
devs mailing list

Reply via email to