Thursday, September 16, 2010

Re: Unchecked exceptions from server to client

Hi,

And thanks for your continuing interest in this subject.

>    void getObject() throws RuntimeException; // or our
> GwtClientException
> }
> Problem is gone... Every method from service can throw our
> RuntimeExceptions.
>
> Is it feature or a bug?

If you need to declare a RuntimeException, or your own exception
inherited from RuntimeException, I would say it's a bug. Otherwise,
what is the need for unchecked exceptions ? However, it may be tricky
to change, since it seems glued into the way GWT works.

I would be happy to be able to tell GWT, that all instances of (or
instances of subclasses of) GWTClientRuntimeException (a classname i
just invented) should be generated to client side code. This gives me
the freedom to to this on the client side;

try {
myService.callThatMightThrowUp();
}
catch (GWTClientRuntimeException ex) {
if (ex instanceof MyInheritedException1) {
//bla bla
}
else {
if (ex instanceof MyInheritedException2) {
//bla bla
}
}

I think that would be neat.

What do you think ?

:-) Kasper


On Thu, Sep 16, 2010 at 1:55 PM, San0 <sanopl@gmail.com> wrote:
> Hi again,
>
> I did more "research" about our way of handling exceptions.
> Most of our service methods doesnt have any throws declarations but
> all of them have validation, which is throwing runtime exception (here
> we are sending field names with errors).
>
> "Bad" service:
> public interface ExceptionModuleService extends RemoteService {
>    void validate();
>
>    void getObject();
> }
>
> In this case, code from my previous code wont work. GWT will throw
> SerializationException, since it cant serialize GwtClientException,
> which would be thrown in both methods.
> BUT in this case:
> public interface ExceptionModuleService extends RemoteService {
>    void validate();
>
>    void getObject() throws RuntimeException; // or our
> GwtClientException
> }
> Problem is gone... Every method from service can throw our
> RuntimeExceptions.
>
> Is it feature or a bug?
>
> Example code: http://san0.org/gwt/gwt-ex.zip
>
> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To post to this group, send email to google-web-toolkit@googlegroups.com.
> To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment