Client Side Exceptions

4 views
Skip to first unread message

Stephe...@paretopartners.com

unread,
Oct 15, 2008, 5:42:47 AM10/15/08
to Google Web Toolkit
I am finding that often if i throw an exception in the client side
then i have to catch it using "catch (Exception ex)" rather than
"catch (TheActualExceptionThrown ex)".

Does anyone else have this issue as i havent seen any posts on the
issue and it seems pretty annoying.

Thanks,
Steve

Lothar Kimmeringer

unread,
Oct 15, 2008, 5:50:07 AM10/15/08
to Google-We...@googlegroups.com
Stephe...@paretopartners.com schrieb:

> I am finding that often if i throw an exception in the client side
> then i have to catch it using "catch (Exception ex)" rather than
> "catch (TheActualExceptionThrown ex)".

Is your own exception derived from SerializableException
or directly from Exception. If it's the latter, try to
derive it from SerializableException.

> Does anyone else have this issue as i havent seen any posts on the
> issue and it seems pretty annoying.

Not that I'm aware of.


Regards, Lothar

walden

unread,
Oct 15, 2008, 8:53:22 AM10/15/08
to Google Web Toolkit
Stephen,

When you say "i have to catch it using..." you are giving an
interpretation of the problem (or rather, your solution) instead of
the problem itself. What happens if you write code to catch the exact
exception thrown?

Walden

On Oct 15, 5:42 am, "Stephen.sm...@paretopartners.com"

Stephe...@paretopartners.com

unread,
Oct 15, 2008, 10:04:19 AM10/15/08
to Google Web Toolkit
Sorry i forgot to mention this has always been a web mode issue for
me. Hosted is fine

Ive only really had this problem with runtime exceptions (although
after having this problem twice i just catch "Exception"). I first
found it when i had some code like this:

private Widget o;

public Object getO() {}
public void setO(Widget o) {}

public void doSomething() {
try {
o.aMethod();
} catch (NullPointerException ex) {
System.out.println("caught");
return;
}
System.out.println("Not caught"):
}

with the resulting output:
Not caught

and when using the debugger i can clearly see its throwing a null.
and if i add something like Window.alert(ex.getCause()); and make it
catch Exception and run it in web mode i get something similar to
NullPointerException (renamed because its JS i assume but practically
the same). Sorry i cant remember exactly what it was called. I cant
possibly the only person thats come across this???
> > Steve- Hide quoted text -
>
> - Show quoted text -

Stephe...@paretopartners.com

unread,
Oct 17, 2008, 6:34:59 AM10/17/08
to Google Web Toolkit
and again a similar example, this time not checking for an exception,
just null. in web mode only...

String searchDept = Cookies.getCookie("signoff department");
if (searchDept == null || searchDept.equals("All")) {
Window.alert("caught!");
}

Please feel free to try it and confirm this because its driving me
mad.
And yes i did clear my cookies befor and i still got it. I think, and
i could be wrong that this is something to do with the difference
between null and "undefined" in JS. but im no JS programmer.

On Oct 15, 3:04 pm, "Stephen.sm...@paretopartners.com"
> > - Show quoted text -- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages