]> www.average.org Git - WhereAmI.git/commitdiff
Network access error message
authorEugene Crosser <crosser@average.org>
Sat, 11 Feb 2012 10:51:03 +0000 (14:51 +0400)
committerEugene Crosser <crosser@average.org>
Sat, 11 Feb 2012 10:51:03 +0000 (14:51 +0400)
res/values/strings.xml
src/org/average/whereami/APIBase.java
src/org/average/whereami/LastLocation.java
src/org/average/whereami/PhoneLog.java

index fe162bbeb3688b07b42e7bd387da4716c3d8d400..0800bbf4505e7ffbf6395ae1dc0c0b325c1c10a8 100644 (file)
@@ -10,6 +10,7 @@
     <string name="nocalendar">Нет календаря с именем</string>
     <string name="noevents">Нет записей за последнюю неделю</string>
     <string name="autherror">Ошибка авторизации</string>
     <string name="nocalendar">Нет календаря с именем</string>
     <string name="noevents">Нет записей за последнюю неделю</string>
     <string name="autherror">Ошибка авторизации</string>
+    <string name="connecterror">Нет связи с сервером через Интернет</string>
     <string name="myname">Женя</string>
     <string name="registered">отмечено</string>
     <string name="last_call">Последний звонок</string>
     <string name="myname">Женя</string>
     <string name="registered">отмечено</string>
     <string name="last_call">Последний звонок</string>
index e8dfbb17a30eb5b002b074997ee34b88fc7c8884..e04f3a5da740eda597a32c7d2cd2479ba5a3bab5 100644 (file)
@@ -33,6 +33,7 @@ public class APIBase {
        public MyAccessProtectedResource accessProtectedResource;
 
        public String authErrorMessage;
        public MyAccessProtectedResource accessProtectedResource;
 
        public String authErrorMessage;
+       public String connectErrorMessage;
 
        public APIBase(final Resources res, final PersistentStore store) {
                this.res = res;
 
        public APIBase(final Resources res, final PersistentStore store) {
                this.res = res;
@@ -50,6 +51,7 @@ public class APIBase {
                        ClientCredentials.CLIENT_SECRET,
                        token.refreshToken);
                authErrorMessage = res.getString(R.string.autherror);
                        ClientCredentials.CLIENT_SECRET,
                        token.refreshToken);
                authErrorMessage = res.getString(R.string.autherror);
+               connectErrorMessage = res.getString(R.string.connecterror);
                enableLogging();
        }
 
                enableLogging();
        }
 
index c5791160298ab42ece4bf5f4950b100561938a6c..27c5c51f8f4909e0b7fdc2c7a925270c0897b9c2 100644 (file)
@@ -8,6 +8,8 @@ import org.average.whereami.SayWhen;
 
 import java.lang.Math;
 import java.io.IOException;
 
 import java.lang.Math;
 import java.io.IOException;
+import java.net.UnknownHostException;
+import org.apache.http.conn.HttpHostConnectException;
 
 import com.google.api.client.googleapis.json.GoogleJsonResponseException;
 import com.google.api.client.http.HttpResponseException;
 
 import com.google.api.client.googleapis.json.GoogleJsonResponseException;
 import com.google.api.client.http.HttpResponseException;
@@ -77,6 +79,16 @@ public final class LastLocation extends Oracle {
                 } catch (HttpResponseException e) {
                        Log.e(TAG, "HttpResponseException: " + e);
                        return new Utterance(false, e.getMessage());
                 } catch (HttpResponseException e) {
                        Log.e(TAG, "HttpResponseException: " + e);
                        return new Utterance(false, e.getMessage());
+               } catch (UnknownHostException e) {
+                       Log.e(TAG, "UnknownHostException: " + e);
+                       return new Utterance(false,
+                                       base.connectErrorMessage + "\n" +
+                                       e.getMessage());
+               } catch (HttpHostConnectException e) {
+                       Log.e(TAG, "HttpHostConnectException: " + e);
+                       return new Utterance(false,
+                                       base.connectErrorMessage + "\n" +
+                                       e.getMessage());
                } catch (IOException e) {
                        Log.e(TAG, "IOException: " + e);
                        return new Utterance(false, e.getMessage());
                } catch (IOException e) {
                        Log.e(TAG, "IOException: " + e);
                        return new Utterance(false, e.getMessage());
index cf904c67a5038e5e515a2fbdf23bdb515bc07538..7ce53eaa06920e39f08566f7699aca4f07047400 100644 (file)
@@ -7,6 +7,8 @@ import org.average.whereami.PersistentStore;
 import org.average.whereami.SayWhen;
 
 import java.io.IOException;
 import org.average.whereami.SayWhen;
 
 import java.io.IOException;
+import java.net.UnknownHostException;
+import org.apache.http.conn.HttpHostConnectException;
 
 import com.google.api.client.googleapis.json.GoogleJsonResponseException;
 import com.google.api.client.http.HttpResponseException;
 
 import com.google.api.client.googleapis.json.GoogleJsonResponseException;
 import com.google.api.client.http.HttpResponseException;
@@ -96,6 +98,16 @@ public final class PhoneLog extends Oracle {
                } catch (HttpResponseException e) {
                        Log.e(TAG, "HttpResponseException: " + e);
                        return new Utterance(false, e.getMessage());
                } catch (HttpResponseException e) {
                        Log.e(TAG, "HttpResponseException: " + e);
                        return new Utterance(false, e.getMessage());
+               } catch (UnknownHostException e) {
+                       Log.e(TAG, "UnknownHostException: " + e);
+                       return new Utterance(false,
+                                       base.connectErrorMessage + "\n" +
+                                       e.getMessage());
+               } catch (HttpHostConnectException e) {
+                       Log.e(TAG, "HttpHostConnectException: " + e);
+                       return new Utterance(false,
+                                       base.connectErrorMessage + "\n" +
+                                       e.getMessage());
                } catch (IOException e) {
                        Log.e(TAG, "IOException: " + e);
                        return new Utterance(false, e.getMessage());
                } catch (IOException e) {
                        Log.e(TAG, "IOException: " + e);
                        return new Utterance(false, e.getMessage());