[Android] Catch exceptions in cutsom directories fetching

Geoffrey Métais git at videolan.org
Fri Feb 1 12:02:47 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb  1 11:27:30 2019 +0100| [a0af0bbe811188e9babe047015ef23b18351d2ff] | committer: Geoffrey Métais

Catch exceptions in cutsom directories fetching

> https://code.videolan.org/videolan/vlc-android/commit/a0af0bbe811188e9babe047015ef23b18351d2ff
---

 .../src/org/videolan/vlc/repository/DirectoryRepository.kt        | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/repository/DirectoryRepository.kt b/vlc-android/src/org/videolan/vlc/repository/DirectoryRepository.kt
index 5529a01fb..d81e0064f 100644
--- a/vlc-android/src/org/videolan/vlc/repository/DirectoryRepository.kt
+++ b/vlc-android/src/org/videolan/vlc/repository/DirectoryRepository.kt
@@ -24,7 +24,13 @@ class DirectoryRepository (private val customDirectoryDao: CustomDirectoryDao) :
             customDirectoryDao.insert(CustomDirectory(path))
     }
 
-    suspend fun getCustomDirectories() = withContext(coroutineContext) { customDirectoryDao.getAll() }
+    suspend fun getCustomDirectories() = withContext(coroutineContext) {
+        try {
+            customDirectoryDao.getAll()
+        } catch (e: Exception) {
+            emptyList<CustomDirectory>()
+        }
+    }
 
     fun deleteCustomDirectory(path: String) = launch { customDirectoryDao.delete(CustomDirectory(path)) }
 



More information about the Android mailing list