Google Web Toolkit: exception translation for unchecked exceptions
Is there any possibility to prevent that GWT is translating any unchecked exception to an "InvocationException"?
For example a ServletException is thrown on the server side - GWT is translating this exception into an InvocationException and capsulates the ServletException in the message body as html text. That is a normal behaviour but I want to prevent this.
Is there a way to control this translation mechanism manually? So that I maybe catch the ServletException and throw an specific Exception instead of throwing an unspecific开发者_StackOverflow中文版 InvocationException.
(I am using GWT 2.0)
cheers
No, unchecked exceptions are not serialized and sent to the client (browser). There is no way to make every possible exception serializable, since compiler does not know of all possible exceptions that can be throws to create JavaScript code for them.
You should log your exception at the server side and send error code to the client. If you need stack trace on the client side (that means in user's browser - what is really unusual) you must serialize it manually, logging it into StringOutputStream for example.
精彩评论