diff --git a/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt b/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt index 1ab3cc942..fbbda5380 100644 --- a/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt +++ b/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt @@ -89,7 +89,7 @@ object AppWebDav { } } } else { - throw Exception("Web dav no back up file") + throw NoStackTraceException("Web dav no back up file") } } diff --git a/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt b/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt index f03129e8a..501d5007d 100644 --- a/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt +++ b/app/src/main/java/io/legado/app/model/rss/RssParserByRule.kt @@ -5,6 +5,7 @@ import io.legado.app.R import io.legado.app.data.entities.RssArticle import io.legado.app.data.entities.RssSource import io.legado.app.model.Debug +import io.legado.app.model.NoStackTraceException import io.legado.app.model.analyzeRule.AnalyzeRule import io.legado.app.model.analyzeRule.RuleDataInterface import io.legado.app.utils.GSON @@ -26,7 +27,7 @@ object RssParserByRule { val sourceUrl = rssSource.sourceUrl var nextUrl: String? = null if (body.isNullOrBlank()) { - throw Exception( + throw NoStackTraceException( appCtx.getString(R.string.error_get_web_content, rssSource.sourceUrl) ) } diff --git a/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt b/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt index 12617ce58..5897a4509 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt @@ -7,6 +7,7 @@ import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.rule.TocRule import io.legado.app.model.Debug +import io.legado.app.model.NoStackTraceException import io.legado.app.model.TocEmptyException import io.legado.app.model.analyzeRule.AnalyzeRule import io.legado.app.model.analyzeRule.AnalyzeUrl @@ -30,7 +31,7 @@ object BookChapterList { baseUrl: String, body: String? ): List { - body ?: throw Exception( + body ?: throw NoStackTraceException( appCtx.getString(R.string.error_get_web_content, baseUrl) ) val chapterList = ArrayList() diff --git a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt index f9b9b64ee..edc3b43b5 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt @@ -9,6 +9,7 @@ import io.legado.app.data.entities.rule.ContentRule import io.legado.app.help.BookHelp import io.legado.app.model.ContentEmptyException import io.legado.app.model.Debug +import io.legado.app.model.NoStackTraceException import io.legado.app.model.analyzeRule.AnalyzeRule import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.utils.HtmlFormatter @@ -34,7 +35,7 @@ object BookContent { body: String?, nextChapterUrl: String? = null ): String { - body ?: throw Exception( + body ?: throw NoStackTraceException( appCtx.getString(R.string.error_get_web_content, baseUrl) ) Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}") diff --git a/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt b/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt index d53dd1ce9..40486e778 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt @@ -5,6 +5,7 @@ import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookSource import io.legado.app.help.BookHelp import io.legado.app.model.Debug +import io.legado.app.model.NoStackTraceException import io.legado.app.model.analyzeRule.AnalyzeRule import io.legado.app.utils.HtmlFormatter import io.legado.app.utils.NetworkUtils @@ -25,7 +26,7 @@ object BookInfo { body: String?, canReName: Boolean, ) { - body ?: throw Exception( + body ?: throw NoStackTraceException( appCtx.getString(R.string.error_get_web_content, baseUrl) ) Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}") diff --git a/app/src/main/java/io/legado/app/model/webBook/BookList.kt b/app/src/main/java/io/legado/app/model/webBook/BookList.kt index 1599ac274..47e89d5b1 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookList.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookList.kt @@ -7,6 +7,7 @@ import io.legado.app.data.entities.SearchBook import io.legado.app.data.entities.rule.BookListRule import io.legado.app.help.BookHelp import io.legado.app.model.Debug +import io.legado.app.model.NoStackTraceException import io.legado.app.model.analyzeRule.AnalyzeRule import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.utils.HtmlFormatter @@ -28,7 +29,7 @@ object BookList { body: String?, isSearch: Boolean = true, ): ArrayList { - body ?: throw Exception( + body ?: throw NoStackTraceException( appCtx.getString( R.string.error_get_web_content, analyzeUrl.ruleUrl diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 6df5dc8d0..1e167271c 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -13,6 +13,7 @@ import io.legado.app.help.AppConfig import io.legado.app.help.coroutine.CompositeCoroutine import io.legado.app.model.CheckSource import io.legado.app.model.Debug +import io.legado.app.model.NoStackTraceException import io.legado.app.model.webBook.WebBook import io.legado.app.ui.book.source.manage.BookSourceActivity import io.legado.app.utils.activityPendingIntent @@ -128,7 +129,7 @@ class CheckSourceService : BaseService() { } } if (url.isNullOrBlank()) { - throw Exception("搜索内容为空并且没有发现") + throw NoStackTraceException("搜索内容为空并且没有发现") } books = WebBook.exploreBookAwait(this, source, url) } @@ -137,7 +138,7 @@ class CheckSourceService : BaseService() { val content = WebBook.getContentAwait(this, source, book, toc.first(), toc.getOrNull(1)?.url) if (content.isBlank()) { - throw Exception("正文内容为空") + throw NoStackTraceException("正文内容为空") } }.timeout(180000L) .onError(searchCoroutine) { diff --git a/app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt b/app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt index 06092e3d9..e3e5533a0 100644 --- a/app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt @@ -5,6 +5,7 @@ import android.net.Uri import androidx.documentfile.provider.DocumentFile import androidx.lifecycle.MutableLiveData import io.legado.app.base.BaseViewModel +import io.legado.app.model.NoStackTraceException import io.legado.app.model.localBook.LocalBook import io.legado.app.utils.isJson import io.legado.app.utils.printOnDebug @@ -49,7 +50,7 @@ class FileAssociationViewModel(application: Application) : BaseViewModel(applica } val book = LocalBook.importFile(uri) openBookLiveData.postValue(book.bookUrl) - } ?: throw Exception("文件不存在") + } ?: throw NoStackTraceException("文件不存在") } else { onLineImportLive.postValue(uri) } diff --git a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt index 530063a15..0d1b38103 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt @@ -15,6 +15,7 @@ import io.legado.app.help.SourceHelp import io.legado.app.help.http.newCall import io.legado.app.help.http.okHttpClient import io.legado.app.help.http.text +import io.legado.app.model.NoStackTraceException import io.legado.app.utils.* class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) { @@ -114,7 +115,7 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) { mText.isAbsUrl() -> { importSourceUrl(mText) } - else -> throw Exception(context.getString(R.string.wrong_format)) + else -> throw NoStackTraceException(context.getString(R.string.wrong_format)) } }.onError { it.printOnDebug() @@ -144,7 +145,7 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) { } } else -> { - throw Exception(context.getString(R.string.wrong_format)) + throw NoStackTraceException(context.getString(R.string.wrong_format)) } } } diff --git a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt index c28d4c3f7..da0f2c6eb 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt @@ -13,6 +13,7 @@ import io.legado.app.help.SourceHelp import io.legado.app.help.http.newCall import io.legado.app.help.http.okHttpClient import io.legado.app.help.http.text +import io.legado.app.model.NoStackTraceException import io.legado.app.utils.* class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) { @@ -111,7 +112,7 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) { mText.isAbsUrl() -> { importSourceUrl(mText) } - else -> throw Exception(context.getString(R.string.wrong_format)) + else -> throw NoStackTraceException(context.getString(R.string.wrong_format)) } }.onError { errorLiveData.postValue("ImportError:${it.localizedMessage}") diff --git a/app/src/main/java/io/legado/app/ui/association/OnLineImportViewModel.kt b/app/src/main/java/io/legado/app/ui/association/OnLineImportViewModel.kt index 5dd4fbea3..132133143 100644 --- a/app/src/main/java/io/legado/app/ui/association/OnLineImportViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/association/OnLineImportViewModel.kt @@ -12,6 +12,7 @@ import io.legado.app.help.ThemeConfig import io.legado.app.help.http.newCall import io.legado.app.help.http.okHttpClient import io.legado.app.help.http.text +import io.legado.app.model.NoStackTraceException import io.legado.app.utils.GSON import io.legado.app.utils.fromJsonArray import io.legado.app.utils.fromJsonObject @@ -56,11 +57,11 @@ class OnLineImportViewModel(app: Application) : BaseViewModel(app) { if (json.isJsonArray()) { GSON.fromJsonArray(json)?.let { appDb.txtTocRuleDao.insert(*it.toTypedArray()) - } ?: throw Exception("格式不对") + } ?: throw NoStackTraceException("格式不对") } else { GSON.fromJsonObject(json)?.let { appDb.txtTocRuleDao.insert(it) - } ?: throw Exception("格式不对") + } ?: throw NoStackTraceException("格式不对") } }.onSuccess { finally.invoke(context.getString(R.string.success), "导入Txt规则成功") @@ -78,12 +79,12 @@ class OnLineImportViewModel(app: Application) : BaseViewModel(app) { GSON.fromJsonArray(json)?.let { appDb.httpTTSDao.insert(*it.toTypedArray()) return@execute it.size - } ?: throw Exception("格式不对") + } ?: throw NoStackTraceException("格式不对") } else { GSON.fromJsonObject(json)?.let { appDb.httpTTSDao.insert(it) return@execute 1 - } ?: throw Exception("格式不对") + } ?: throw NoStackTraceException("格式不对") } }.onSuccess { finally.invoke(context.getString(R.string.success), "导入${it}朗读引擎") @@ -100,11 +101,11 @@ class OnLineImportViewModel(app: Application) : BaseViewModel(app) { if (json.isJsonArray()) { GSON.fromJsonArray(json)?.forEach { ThemeConfig.addConfig(it) - } ?: throw Exception("格式不对") + } ?: throw NoStackTraceException("格式不对") } else { GSON.fromJsonObject(json)?.let { ThemeConfig.addConfig(it) - } ?: throw Exception("格式不对") + } ?: throw NoStackTraceException("格式不对") } }.onSuccess { finally.invoke(context.getString(R.string.success), "导入主题成功") diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index 0ccf1bf06..8dbd19949 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -14,6 +14,7 @@ import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.ContentProcessor import io.legado.app.help.storage.AppWebDav +import io.legado.app.model.NoStackTraceException import io.legado.app.model.ReadAloud import io.legado.app.model.ReadBook import io.legado.app.model.localBook.LocalBook @@ -199,7 +200,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { WebBook.preciseSearch(this, sources, name, author)?.let { it.second.upInfoFromOld(ReadBook.book) changeTo(it.first, it.second) - } ?: throw Exception("自动换源失败") + } ?: throw NoStackTraceException("自动换源失败") }.onStart { ReadBook.upMsg(context.getString(R.string.source_auto_changing)) }.onError { diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt index 04571491f..4009b7cee 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt @@ -10,6 +10,7 @@ import io.legado.app.help.DefaultData import io.legado.app.help.http.newCall import io.legado.app.help.http.okHttpClient import io.legado.app.help.http.text +import io.legado.app.model.NoStackTraceException import io.legado.app.utils.* class SpeakEngineViewModel(application: Application) : BaseViewModel(application) { @@ -61,7 +62,7 @@ class SpeakEngineViewModel(application: Application) : BaseViewModel(application } } else -> { - throw Exception("格式不对") + throw NoStackTraceException("格式不对") } } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt index 9ae0066c7..f1022171b 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt @@ -9,6 +9,7 @@ import io.legado.app.data.entities.BookSource import io.legado.app.help.http.newCall import io.legado.app.help.http.okHttpClient import io.legado.app.help.http.text +import io.legado.app.model.NoStackTraceException import io.legado.app.model.webBook.WebBook import io.legado.app.utils.* import kotlinx.coroutines.Dispatchers.IO @@ -50,7 +51,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application) it.save() successCount++ }.onError { - throw Exception(it.localizedMessage) + throw it } } } @@ -96,7 +97,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application) importBookshelfByJson(text, groupId) } else -> { - throw Exception("格式不对") + throw NoStackTraceException("格式不对") } } }.onError {