简体   繁体   English

如何从GWT的客户端向服务器发送Exception对象?

[英]How to send an Exception object from GWT's client to server?

I'm trying to log client's exceptions on the server side. 我正在尝试在服务器端记录客户端的异常。 So I need to send them from client to server. 所以我需要将它们从客户端发送到服务器。

I have created service for this purpose: 我为此创建了服务:

public interface LoggerService extends RemoteService {
    void logerror(Throwable e);
}

On the client's side I use GWT.setUncaughtExceptionHandler(uncaughtExceptionHandler): 在客户端,我使用GWT.setUncaughtExceptionHandler(uncaughtExceptionHandler):

GWT.UncaughtExceptionHandler uncaughtExceptionHandler = new
    GWT.UncaughtExceptionHandler() {
          public void onUncaughtException(Throwable e) {

            LoggerServiceAsync loggerService = GWT.create(LoggerService.class);
            loggerService.logerror(e, new AsyncCallback<Void>() {
                @Override
                public void onSuccess(Void arg0) {
                    SC.say("Client's error logged");

                }
                @Override
                public void onFailure(Throwable arg0) {
                    SC.say("Unable to log client's error");

                }
            });  
          }
        };

When I'm using hosted mode it works fine. 当我使用托管模式时,它可以正常工作。 But when I'm trying to work with web mode My LoggerService doesn't work. 但是,当我尝试使用网络模式时,我的LoggerService无法正常工作。 I know that in hosted mode exception "translates" from js to java. 我知道在托管模式下,异常会从js“转换”为java。 But I can't understand, why my logerror(Throwable e) method doesn't invoke at all in web mode. 但是我不明白,为什么我的logerror(Throwable e)方法根本不在Web模式下调用。 Server responce is 200. 服务器响应为200。

GWT offers infrastructure that facilitates client side logging with support for sending your log messages to the server. GWT提供了便利于客户端日志记录的基础架构,并支持将日志消息发送到服务器。 It'll slightly complicate your implementation at first but might establish a way to do logging across your app. 刚开始时,它会使您的实现稍微复杂一些,但可能会建立一种跨应用程序进行日志记录的方法。

最后,我添加了gwt-log用于在服务器上记录客户端的异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 GWT(Client)=如何将Object转换为JSON并发送到Server? - GWT (Client) = How to convert Object to JSON and send to Server? 如何从服务器(appengine)获取日期对象并将其转换为客户端的时区日期(gwt)? - How can I get a date object from server (appengine) and convert it to client's timezone's date (gwt)? 如何将 URL 参数从 GWT 客户端发送到服务器端进行验证 - How to send URL parameters from GWT client to Server side for validation 如何从服务器向客户端发送对象JdbcRowSet? - how to send an object JdbcRowSet from server to the client? 如何从客户端向服务器发送对象? - How send an object to server from client? 从客户端[GWT]向服务器端[Spring]发送对象的日期之间的时间间隔 - Time lag between date send in object from client side [GWT] to server side [Spring ] 使用GWT将数据对象从客户端传输到服务器以保持数据的方式是什么? - What's the way you transfer data object from client to server for persisting datas using GWT? GWT从服务器向客户端发送大量数据的最佳实践 - GWT Best practice to send huge amount of data from server to client 如何使用Java将对象从服务器发送到客户端? - How I can send a object from server to Client in Java? 如何使用Java将对象从客户端发送到服务器? - How I can send a object from Client to Server in Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM