我怎样才能让OpenDolphin客户端发送HttpHostConnectException?

时间:2013-10-06 09:08:41

标签: client-server http-host opendolphin

有没有办法处理邮件未送达服务器的情况?海豚日志清楚地表明情况,但我想从代码中捕获它。我正在寻找一些方法,比如: onError 以覆盖 onFinished

clientDolphin.send(message, new OnFinishedHandlerAdapter() {
        @Override
        public void onFinished(List<ClientPresentationModel> presentationModels) {
            // Do something useful
            }
        }
    });

,但没有这样的。在try / catch中包装发送调用也不起作用(因为发送没有阻止其调用者代码,所以并不令人惊讶)。

我确实有一些简单的方法来了解未传递的消息,但我无法看到它。 多士先生,为了答案而获胜!

1 个答案:

答案 0 :(得分:1)

您可以将一个onException处理程序分配给ClientConnector - 实际上您应该这样做。异常处理程序将获取在异步发送操作中发生的异常对象。

下面是默认的处理程序,甚至告诉你,你应该做什么;-)

Closure onException = { Throwable up ->
    def out = new StringWriter()
    up.printStackTrace(new PrintWriter(out))
    log.severe("onException reached, rethrowing in UI Thread, consider setting ClientConnector.onException\n${out.buffer}")
    uiThreadHandler.executeInsideUiThread { throw up } // not sure whether this is a good default
}
相关问题