On 09/21/2010 07:41 PM, Marius Dumitru Florea wrote:
> Hi devs,
>
> I was playing with the office preview script service when I discovered
> that $services throws ScriptServiceNotFoundException when there's no
> script service registered for the specified hint, e.g. $services.foo . I
> was expecting $services to return null when it fails to locate a
> service. I even wrote:
>
> #if($services.officepreview)
>     {{html}}
>     $services.officepreview.preview(...)
>     {{/html}}
> #else
>     {{error}}The office preview component has not been installed.{{/error}}
> #end
>
> What do you think it's best: to throw ScriptServiceNotFoundException or
> to return null?
>
> Anyway, I think there should be a method to check if a script service is
> available (
> http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-script/src/main/java/org/xwiki/script/service/ScriptServiceManager.java
> ).
>
> WDYT?

I'd say that it's really bad that an exception is thrown in the 
frontend. Especially since it can't be caught in Velocity. +1 for 
returning null.

-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to