I misunderstood what you wanted. I thought you wanted to know what the
{{velocity}} or {{groovy}} macros would display. They automatically catch
exceptions. Now it seems your question is different and you wish to be able to
catch exceptions in your own script.
XWiki offers a scripting API for all Java API (for example when you call
$services.xxx). It’s not the same API as the Java API. And our rule is in
general to not throw Exceptions but instead to return null when there are
problems. The main reason was because of Velocity indeed.
That said, we’ve recently introduced a way to catch exceptions in Velocity:
http://www.xwiki.org/xwiki/bin/view/ReleaseNotes/ReleaseNotesXWiki63#HAbilitytocatchExceptionsfromVelocity
Hope it helps
-Vincent
On 28 Nov 2014 at 21:18:56, Bryn Jeffries
([email protected](mailto:[email protected])) wrote:
> Said Vincent:
> > > and can this be caught within the Velocity or Groovy code that calls it?
> >
> > errors are automatically caught in the script macros ({{velocity}},
> > {{groovy}}, etc).
>
> OK, looks like Groovy has explicit try/catch
> (http://groovy.codehaus.org/JN3035-Exceptions). I couldn't see anything about
> Velocity catching exceptions (only about Velocity throwing exceptions -
> http://velocity.apache.org/engine/devel/developer-guide.html#exceptions).
>
> So if I have a component that I call from velocity with $mycomponent.foo()
> and the method throws an exception (IOException, for instance), can I control
> what the Velocity script does about this?
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users