mobile/android/base/sync/HTTPFailureException.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 package org.mozilla.gecko.sync;
michael@0 6
michael@0 7 import org.mozilla.gecko.sync.net.SyncStorageResponse;
michael@0 8
michael@0 9 import android.content.SyncResult;
michael@0 10
michael@0 11 public class HTTPFailureException extends SyncException {
michael@0 12 private static final long serialVersionUID = -5415864029780770619L;
michael@0 13 public SyncStorageResponse response;
michael@0 14
michael@0 15 public HTTPFailureException(SyncStorageResponse response) {
michael@0 16 this.response = response;
michael@0 17 }
michael@0 18
michael@0 19 @Override
michael@0 20 public String toString() {
michael@0 21 String errorMessage;
michael@0 22 try {
michael@0 23 errorMessage = this.response.getErrorMessage();
michael@0 24 } catch (Exception e) {
michael@0 25 // Oh well.
michael@0 26 errorMessage = "[unknown error message]";
michael@0 27 }
michael@0 28 return "<HTTPFailureException " + this.response.getStatusCode() +
michael@0 29 " :: (" + errorMessage + ")>";
michael@0 30 }
michael@0 31
michael@0 32 @Override
michael@0 33 public void updateStats(GlobalSession globalSession, SyncResult syncResult) {
michael@0 34 switch (response.getStatusCode()) {
michael@0 35 case 401:
michael@0 36 // Node reassignment 401s get handled internally.
michael@0 37 syncResult.stats.numAuthExceptions++;
michael@0 38 return;
michael@0 39 case 500:
michael@0 40 case 501:
michael@0 41 case 503:
michael@0 42 // TODO: backoff.
michael@0 43 syncResult.stats.numIoExceptions++;
michael@0 44 return;
michael@0 45 }
michael@0 46 }
michael@0 47 }

mercurial