On 15 Jan 2016 at 10:38:05, vinc...@massol.net 
(vinc...@massol.net(mailto:vinc...@massol.net)) wrote:

>  
>  
> On 15 Jan 2016 at 10:34:58, Thomas Mortagne 
> (thomas.morta...@xwiki.com(mailto:thomas.morta...@xwiki.com)) wrote:
>  
> > On Fri, Jan 15, 2016 at 9:18 AM, vinc...@massol.net wrote:
> > >
> > >
> > > On 15 Jan 2016 at 07:24:35, Marius Dumitru Florea 
> > > (mariusdumitru.flo...@xwiki.com(mailto:mariusdumitru.flo...@xwiki.com)) 
> > > wrote:
> > >
> > >> On Thu, Jan 14, 2016 at 6:51 PM, 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?
> > >> >
> > >>
> > >> +1, it's a pain to call setLastError() everywhere there can be an 
> > >> exception
> > >> thrown, and we almost always forget to do it (for this reason).
> > >>
> > >> Note that we also have the #try() directive now.
> > >
> > > Yes, I should have mentioned that there’s indeed also this possibility:
> > > * Have script API throw Exceptions
> > > * Force velocity script users to wrap their code with the try directive 
> > > when they need to catch exceptions
> > >
> > > I still believe that the use of the Exception-catching uberspector is 
> > > better.
> > >
> > > WDYT?
> >
> > Does it mean you plan to get rid of new #try directive ? Because it
> > will be broken with this new uberspector.  
>  
> That’s a good point, I had not thought about the implementation at this 
> stage.  
>  
> I think this could still work. When the #try directive is used I’d just have 
> to setup some flag somewhere in Velocity and in the uberspector I could check 
> if this flag is set and if so then don’t catch the exception. 


Actually, thinking more, I think you’re right and that the #try directive plays 
exactly the same role as an Exception-catching uberspector and I don’t see the 
need for the #try directive if we provide an uberspector.

So I’m proposing to deprecate it but still keep it for backward compatibility 
for now (probably a full cycle).

WDYT?

Thanks
-Vincent

> Thanks  
> -Vincent
>  
> > > Thanks
> > > -Vincent
> > >
> > >> Thanks,
> > >> Marius
> > >>
> > >>
> > >> >
> > >> > 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

Reply via email to