+1 it certainly makes writing script services much easier (and harder to ignore proper error handling on script side :))
On Thu, Mar 31, 2016 at 3:20 PM, Marius Dumitru Florea <mariusdumitru.flo...@xwiki.com> wrote: > +1 for throwing exceptions in script services and using #try to catch them > if we want. > > Thanks, > Marius > > On Thu, Mar 31, 2016 at 3:17 PM, Vincent Massol <vinc...@massol.net> wrote: > >> Guys, I’d like that we progress on this. >> >> I didn’t get any agreement or disagreement to this proposal. >> >> Any take? >> >> Thanks >> -Vincent >> >> >> > 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. >> > >> > WDYT? >> > >> > 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 >> devs@xwiki.org >> http://lists.xwiki.org/mailman/listinfo/devs >> > _______________________________________________ > devs mailing list > devs@xwiki.org > http://lists.xwiki.org/mailman/listinfo/devs -- Thomas Mortagne _______________________________________________ devs mailing list devs@xwiki.org http://lists.xwiki.org/mailman/listinfo/devs