开发者

How to generate an error that cause little box show up in GWT application?

I want to test does my gwt-log module works as expected in my application. I want to generate some error on client so the little box with error notification show up (it also contains the button "Show more" or something like that which shows the full stack trace if you click on it). I once got it, but if I repeat that same scenario, it simple won't show up. I tried to add exception to handler for edit button:

view.getGridButton().addListener(Events.Select, new SelectionListener<ButtonEvent>() {
    @Override
    public void componentSelected(ButtonEvent ce) {

    throw new RuntimeException("Button开发者_开发问答 Generated Error");
    }

});

... but this doesn't throw exception visible in console, log or screen (browser).

Any suggestions? Thanks.


I think this may be the issue:

Exceptions: try, catch, finally and user-defined exceptions are supported as normal, although Throwable.getStackTrace() is not meaningfully supported in web mode. See:

https://code.google.com/webtoolkit/doc/1.6/DevGuideCodingBasics.html

Are you in web mode when you are running this? Remember that GWT compiles the java code to javascript code under the covers. You may have to use JSNI in order to accomplish this.


I finally found out the cause of the problem. In my Error handler, I called the method Log.error(...) with the error trace and IP address. The problem was in method for fetching IP address, so the log didn't show up in my log file. Your answer @pistolPanties works after this. Many thanks.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜