开发者

Automatically catch all exceptions thrown by BlazeDS remoting methods?

Is there 开发者_如何学JAVAa way to automatically catch all (unchecked) exceptions thrown by BlazeDS remoting methods, without wrapping each one in a last-resort try/catch block? My code catches any checked exceptions as required, but I'd prefer that stray NullPointerExceptions, ArrayIndexOutOfBoundsExceptions and the like don't end up being set to the client.


I would suggest to use Spring-BlazeDs integration project. One of the benefits is the ExceptionTranslator mechanism which can solve your problem, I wrote an article here.

If you cannot use Spring you can take a look in BlazeDS source code and add your own interceptor. The BlazeDS code is clean and not hard to understand.


Take a look at Thread.setDefaultUncaughtExceptionHandler, i guess it gives you just what you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜