about summary refs log tree commit diff stats
path: root/org.fox.ttrss
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-06-06 14:24:02 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-06-06 14:24:02 +0300
commitf9fb62d7282d7e1ec310a12b0fcb922267689d6d (patch)
treef99648471d193d5aac6ef71cc97c98a7c6ef2d1e /org.fox.ttrss
parent4fc32c13fb45a7567cb677bb1c89cb4adcc6c0a9 (diff)
downloadtt-rss-android-f9fb62d7282d7e1ec310a12b0fcb922267689d6d.tar.gz
tt-rss-android-f9fb62d7282d7e1ec310a12b0fcb922267689d6d.tar.xz
store last exception with the apierror just in case
Diffstat (limited to 'org.fox.ttrss')
-rw-r--r--org.fox.ttrss/src/main/java/org/fox/ttrss/ApiCommon.java8
-rw-r--r--org.fox.ttrss/src/main/java/org/fox/ttrss/ApiRequest.java11
-rw-r--r--org.fox.ttrss/src/main/java/org/fox/ttrss/ApiV2Client.java3
-rw-r--r--org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleModel.java11
-rw-r--r--org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsModel.java11
5 files changed, 44 insertions, 0 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiCommon.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiCommon.java
index 6b76048b..a653ac3a 100644
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiCommon.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiCommon.java
@@ -52,9 +52,13 @@ public class ApiCommon {
 
         void setLastErrorMessage(String message);
 
+        void setLastException(Throwable e);
+
         void notifyProgress(int progress);
 
         ApiError getLastError();
+
+        Throwable getLastException();
     }
 
     public enum ApiError {
@@ -497,10 +501,12 @@ public class ApiCommon {
         } catch (javax.net.ssl.SSLPeerUnverifiedException e) {
             caller.setLastError(ApiError.SSL_REJECTED);
             caller.setLastErrorMessage(e.getMessage());
+            caller.setLastException(e);
             Log.e(TAG, "SSL certificate rejected", e);
         } catch (IOException e) {
             caller.setLastError(ApiError.IO_ERROR);
             caller.setLastErrorMessage(e.getMessage());
+            caller.setLastException(e);
 
             if (e.getMessage() != null) {
                 if (e.getMessage().matches("Hostname [^ ]+ was not verified")) {
@@ -512,10 +518,12 @@ public class ApiCommon {
         } catch (com.google.gson.JsonSyntaxException e) {
             caller.setLastError(ApiError.PARSE_ERROR);
             caller.setLastErrorMessage(e.getMessage());
+            caller.setLastException(e);
             Log.e(TAG, "JSON parse error", e);
         } catch (Exception e) {
             caller.setLastError(ApiError.OTHER_ERROR);
             caller.setLastErrorMessage(e.getMessage());
+            caller.setLastException(e);
             Log.e(TAG, "API request failed", e);
         }
 
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiRequest.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiRequest.java
index f26389f7..6c174adf 100644
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiRequest.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiRequest.java
@@ -31,6 +31,7 @@ public class ApiRequest implements ApiCommon.ApiCaller {
     protected int m_apiStatusCode = 0;
     protected String m_lastErrorMessage;
     protected ApiError m_lastError;
+    protected Throwable m_lastException;
 
     public ApiRequest(Context context) {
         m_context = context;
@@ -93,6 +94,11 @@ public class ApiRequest implements ApiCommon.ApiCaller {
     }
 
     @Override
+    public void setLastException(Throwable e) {
+        m_lastException = e;
+    }
+
+    @Override
     public void notifyProgress(int progress) {
         // Progress is no longer tracked via AsyncTask's publishProgress.
         // Subclasses can override if they need progress notifications.
@@ -103,6 +109,11 @@ public class ApiRequest implements ApiCommon.ApiCaller {
         return m_lastError;
     }
 
+    @Override
+    public Throwable getLastException() {
+        return m_lastException;
+    }
+
     /**
      * Shut down the shared executor. Call once when the application is terminating.
      */
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiV2Client.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiV2Client.java
index 4debd418..340c1461 100644
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiV2Client.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiV2Client.java
@@ -207,11 +207,13 @@ public class ApiV2Client {
         } catch (javax.net.ssl.SSLPeerUnverifiedException e) {
             caller.setLastError(ApiError.SSL_REJECTED);
             caller.setLastErrorMessage(e.getMessage());
+            caller.setLastException(e);
             Log.e(TAG, "API response error", e);
             return null;
         } catch (IOException e) {
             caller.setLastError(ApiError.IO_ERROR);
             caller.setLastErrorMessage(e.getMessage());
+            caller.setLastException(e);
 
             if (e.getMessage() != null && e.getMessage().matches("Hostname [^ ]+ was not verified")) {
                 caller.setLastError(ApiError.SSL_HOSTNAME_REJECTED);
@@ -222,6 +224,7 @@ public class ApiV2Client {
         } catch (Exception e) {
             caller.setLastError(ApiError.OTHER_ERROR);
             caller.setLastErrorMessage(e.getMessage());
+            caller.setLastException(e);
             Log.e(TAG, "IO error during request", e);
             return null;
         }
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleModel.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleModel.java
index a8753286..f64155c5 100644
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleModel.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleModel.java
@@ -43,6 +43,7 @@ public class ArticleModel extends AndroidViewModel implements ApiCommon.ApiCalle
 
     private String m_lastErrorMessage;
     private ApiCommon.ApiError m_lastError;
+    private Throwable m_lastException;
     private Feed m_feed;
     private int m_firstId;
     private String m_searchQuery = "";
@@ -371,6 +372,11 @@ public class ArticleModel extends AndroidViewModel implements ApiCommon.ApiCalle
     }
 
     @Override
+    public void setLastException(Throwable e) {
+        m_lastException = e;
+    }
+
+    @Override
     public void notifyProgress(int progress) {
         m_loadingProgress.postValue(progress);
     }
@@ -399,6 +405,11 @@ public class ArticleModel extends AndroidViewModel implements ApiCommon.ApiCalle
         return m_lastError;
     }
 
+    @Override
+    public Throwable getLastException() {
+        return m_lastException;
+    }
+
     String getLastErrorMessage() {
         return m_lastErrorMessage;
     }
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsModel.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsModel.java
index bdd5068e..aeefb08b 100644
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsModel.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsModel.java
@@ -49,6 +49,7 @@ public class FeedsModel extends AndroidViewModel implements ApiCommon.ApiCaller
     private int m_apiStatusCode = 0;
     private String m_lastErrorMessage;
     private ApiCommon.ApiError m_lastError;
+    private Throwable m_lastException;
 
     protected SharedPreferences m_prefs;
 
@@ -75,6 +76,11 @@ public class FeedsModel extends AndroidViewModel implements ApiCommon.ApiCaller
         m_lastErrorMessage = message;
     }
 
+    @Override
+    public void setLastException(Throwable e) {
+        m_lastException = e;
+    }
+
     public void startLoading(Feed feed) {
         Log.d(TAG, "startLoading feed id=" + feed.id + " cat=" + feed.is_cat);
 
@@ -164,6 +170,11 @@ public class FeedsModel extends AndroidViewModel implements ApiCommon.ApiCaller
         return m_lastError;
     }
 
+    @Override
+    public Throwable getLastException() {
+        return m_lastException;
+    }
+
     String getLastErrorMessage() {
         return m_lastErrorMessage;
     }