Authentication with session login in couchbase lite

using sync gateway version : 1.0.4
couchbase server : 3.0.3

I am sharing small snippet ,

This is the code for pushing and pulling the documents with session login authentication, so what is happenning is, here I am passing one “dt” variable in setcookie method of push and pull, that is basically ttl (time to live), suppose now it is expiring , then I am getting error like or log on the console like "SEVERE: ChangeTracker: com.couchbase.lite.replicator.ChangeTracker@2277f8f9: Change tracker got error 401’,

log is not a problem , obviously it would come after session expiration, what I wanted to know how to track this 401 error in the code ,or is there any hook to get it as I want to resync it with new authentication credentials in the setcookie method ,

Initially I thought I would track this in “push.addChangeListener” ,but I am not getting it here too, you can see the code , I have shared it.

I would be highly obliged if you give the reply asap, as I have to show this thing in the POC.
Thanks in advance.

            Replication push = db.createPushReplication(url);
	push.setContinuous(true);
	push.setCookie(json.getString("cookie_name"),
			json.getString("session_id"), null, dt, false, true);
	push.start();

	//System.out.println("Push Is continuous: "+push.isContinuous());
	
	Replication pull = db.createPullReplication(url);
	pull.setContinuous(true);
	pull.setCookie(json.getString("cookie_name"),
			json.getString("session_id"), null, dt, false, true);
	List<String> channels=new ArrayList<String>();
	channels.add("eappmetadata");
	pull.setChannels(channels);
	pull.start();
	//System.out.println("Pull Is continuous: "+pull.isContinuous());
	
	push.addChangeListener(new ChangeListener() {

		@Override
		public void changed(ChangeEvent ev) {
			System.out.println("Error : " + ev.getError());
			System.out.println(ev.getSource().getStatus());
			System.out.println("source : "
					+ ev.getSource().getAuthenticator());

			if (ev.getError() instanceof HttpResponseException) {
				HttpResponseException ex = (HttpResponseException) ev
						.getError();
				System.out.println("status code:  " + ex.getStatusCode()
						+ "  and message is :  " + ex.getMessage());
			}
		}
	});

	pull.addChangeListener(new ChangeListener() {

		@Override
		public void changed(ChangeEvent ev) {
			System.out.println("Error : " + ev.getError());
			System.out.println(ev.getSource().getStatus());
			System.out.println("source : "
					+ ev.getSource().getAuthenticator());
			if (ev.getError() instanceof HttpResponseException) {
				HttpResponseException ex = (HttpResponseException) ev
						.getError();
				System.out.println("status code:  " + ex.getStatusCode()
						+ "  and message is :  " + ex.getMessage());
			}
		}
	});

I think you can catch the 401 error on the lastError property of the replication object http://developer.couchbase.com/documentation/mobile/1.1.0/develop/references/couchbase-lite/couchbase-lite/replication/replication/index.html

James