How to capture network error exception on CBL?

29 views
Skip to first unread message

Indrajaya :)

unread,
Mar 12, 2015, 2:39:25 AM3/12/15
to mobile-c...@googlegroups.com
Hello!

I want to capture any exception regarding to network exception (e.g. connection timeout, etc) when I start replication. Can someone tell me how to do it? Thank you.


Indrajaya :)

unread,
Mar 12, 2015, 2:43:45 AM3/12/15
to mobile-c...@googlegroups.com
Sorry, missing information. I'm using android. My snapshot code below :

MyApplication.java
==============
private Replication.ChangeListener getReplicationChangeListener() {
    return new Replication.ChangeListener() {
        @Override
        public void changed(Replication.ChangeEvent event) {
            Replication replication = event.getSource();
            if (event.getError() != null) {
                Throwable lastError = event.getError();
                if (lastError instanceof ConnectTimeoutException) {
                    ConnectTimeoutException connectTimeoutException = (ConnectTimeoutException) lastError;
                    onSyncConnectTimeoutObservable.notifyChanges(connectTimeoutException.getMessage());
                }
            }
        }
    }
}


Thank you.

Hideki Itakura

unread,
Mar 12, 2015, 12:59:48 PM3/12/15
to mobile-c...@googlegroups.com
Hi Indrajaya,
The replicator notifies error if error is transient. ConnectTimeoutException might not be notified.
Thanks,

Hideki Itakura

unread,
Mar 12, 2015, 1:01:19 PM3/12/15
to mobile-c...@googlegroups.com

The replicator notifies error if error is not transient.

Indrajaya :)

unread,
Mar 16, 2015, 8:08:39 PM3/16/15
to mobile-c...@googlegroups.com
Hi Hideki,

Can you give a simple clue how to implement your way. Is there any missing code that I supplied before?

--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/907e283a-284c-4718-acd7-2b97214f3fdf%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Jens Alfke

unread,
Mar 17, 2015, 1:14:34 AM3/17/15
to mobile-c...@googlegroups.com

On Mar 16, 2015, at 5:08 PM, Indrajaya :) <jay0...@gmail.com> <jay0...@gmail.com> wrote:

Can you give a simple clue how to implement your way. Is there any missing code that I supplied before?

You’re not going to see those errors at all, because the replicator handles them internally. What you will see is the replication going online/offline, which you can watch via its ‘status’ property.

—Jens
Reply all
Reply to author
Forward
0 new messages