From f7e9df69baf13286d55420c16e7dc9b1207d0373 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 8 Dec 2022 17:51:22 +0100 Subject: [PATCH] fix crash when importing playlists of wrong format --- .../java/com/github/libretube/util/ImportHelper.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/util/ImportHelper.kt b/app/src/main/java/com/github/libretube/util/ImportHelper.kt index b0682abb3..569bba21b 100644 --- a/app/src/main/java/com/github/libretube/util/ImportHelper.kt +++ b/app/src/main/java/com/github/libretube/util/ImportHelper.kt @@ -115,8 +115,15 @@ class ImportHelper( val playlistFile = ObjectMapper().readValue(uri.readText(), ImportPlaylistFile::class.java) CoroutineScope(Dispatchers.IO).launch { - playlistFile.playlists?.let { - PlaylistsHelper.importPlaylists(activity, it) + try { + playlistFile.playlists?.let { + PlaylistsHelper.importPlaylists(activity, it) + } + } catch (e: Exception) { + Log.e(TAG(), e.toString()) + e.localizedMessage?.let { + activity.applicationContext.toastFromMainThread(it) + } } }