About uncheckedException handle?

0 views
Skip to first unread message

L.J.W

unread,
Dec 14, 2009, 3:50:38 AM12/14/09
to gwt-sl
Hi all,I throw a BizException(extends from RuntimeException) in my
rpc service,and BizException type not in the method's signature,how
can I get the BizException instance in the client?Now,the exception
get in client is:

com.google.gwt.user.client.rpc.StatusCodeException: The call failed on
the server; see server log for details

following is code:

public class BizException extends RuntimeException {

public BizException () {
super();
}

public BizException (String message) {
super(message);
}

...

public interface ContactManager extends RemoteService {

public List<Contact> getAllContact()

...

public List<Contact> getAllContact() {
...
throw new BizException ("this is a biz exception");

...

And if I add BizException type to the method's signature,etc:

public List<Contact> getAllContact() throws BizException

It's ok,But I don't want add method signature.

Any advice is appreciated.

Thanks and Best rgds

L.J.W

George Georgovassilis

unread,
Dec 15, 2009, 11:47:25 AM12/15/09
to gwt-sl
Hello L.J.W,

I know, it is ugly, but it's the only reliable way I know of. Your
exception will habe to inherit from IsSerializable and be declared in
the service interface. The reason is that the GWT compiler can know
about this exception only if it is present in the interface -
remember, there is no runtime reflection, so the code running on the
client cannot just look into the RPC payload and infer your otherwise
unknown exception

L.J.W

unread,
Dec 15, 2009, 8:10:39 PM12/15/09
to gwt-sl
Hi George,Thanks for your reply.I want to catch all the exception and
translate to my GeneralException type,this GeneralException inherit
from IsSerializable and know by GWT Compiler.But I don't want to
declare 'throws GeneralException' in every method.any advice?



On 12月16日, 上午12时47分, George Georgovassilis

David Durham

unread,
Jan 26, 2010, 2:10:38 PM1/26/10
to gwt...@googlegroups.com
On Tue, Dec 15, 2009 at 7:10 PM, L.J.W <ljw7...@gmail.com> wrote:
> Hi George,Thanks for your reply.I want to catch all the exception and
> translate to my GeneralException type,this GeneralException inherit
> from IsSerializable and know by GWT Compiler.But I don't want to
> declare 'throws GeneralException' in every method.any advice?

Related info in this thread:

http://groups.google.com/group/gwt-sl/browse_thread/thread/a6c5659079be03d8

I think you can accomplish what you want by extending a gwt-sl framework class.

-Dave

George Georgovassilis

unread,
Jan 27, 2010, 7:01:35 PM1/27/10
to gwt-sl
Hello LJW,

Dave made a good suggestion. You will notice that the
GWTRPCServiceExporter has a bunch of handleXyzException methods which
are meant to process the most common type of exceptions. You could
override doUnexpectedFailure and package your exception into anything
you like.

On Jan 26, 8:10 pm, David Durham <david.durham...@gmail.com> wrote:


> On Tue, Dec 15, 2009 at 7:10 PM, L.J.W <ljw79...@gmail.com> wrote:
> > Hi George,Thanks for your reply.I want to catch all the exception and
> > translate to my GeneralException type,this GeneralException inherit
> > from IsSerializable and know by GWT Compiler.But I don't want to
> > declare 'throws GeneralException' in every method.any advice?
>
> Related info in this thread:
>

> http://groups.google.com/group/gwt-sl/browse_thread/thread/a6c5659079...

Reply all
Reply to author
Forward
0 new messages