pull/2247/head
kunfei 2 years ago
parent bcce51c002
commit f4f7c7063e
  1. 2
      app/src/main/java/io/legado/app/api/controller/BookController.kt
  2. 4
      app/src/main/java/io/legado/app/help/ContentProcessor.kt
  3. 4
      app/src/main/java/io/legado/app/help/CrashHandler.kt
  4. 13
      app/src/main/java/io/legado/app/help/JsExtensions.kt
  5. 16
      app/src/main/java/io/legado/app/model/Debug.kt
  6. 4
      app/src/main/java/io/legado/app/model/ReadBook.kt
  7. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt
  8. 4
      app/src/main/java/io/legado/app/ui/book/explore/ExploreShowViewModel.kt
  9. 5
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  10. 2
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  11. 2
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt
  12. 4
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.kt
  13. 2
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt
  14. 2
      app/src/main/java/io/legado/app/utils/ContextExtensions.kt
  15. 2
      app/src/main/java/io/legado/app/utils/ThrowableExtensions.kt

@ -188,7 +188,7 @@ object BookController {
}
returnData.setData(content)
} catch (e: Exception) {
returnData.setErrorMsg(e.msg)
returnData.setErrorMsg(e.stackTraceStr)
}
return returnData
}

@ -9,8 +9,8 @@ import io.legado.app.data.entities.ReplaceRule
import io.legado.app.exception.RegexTimeoutException
import io.legado.app.help.config.AppConfig
import io.legado.app.help.config.ReadBookConfig
import io.legado.app.utils.msg
import io.legado.app.utils.replace
import io.legado.app.utils.stackTraceStr
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.CancellationException
import splitties.init.appCtx
@ -149,7 +149,7 @@ class ContentProcessor private constructor(
} catch (e: RegexTimeoutException) {
item.isEnabled = false
appDb.replaceRuleDao.update(item)
return item.name + e.msg
return item.name + e.stackTraceStr
} catch (e: CancellationException) {
return mContent
} catch (e: Exception) {

@ -8,7 +8,7 @@ import io.legado.app.model.ReadAloud
import io.legado.app.utils.FileUtils
import io.legado.app.utils.getFile
import io.legado.app.utils.longToastOnUi
import io.legado.app.utils.msg
import io.legado.app.utils.stackTraceStr
import splitties.init.appCtx
import java.io.PrintWriter
import java.io.StringWriter
@ -48,7 +48,7 @@ class CrashHandler(val context: Context) : Thread.UncaughtExceptionHandler {
if (ex == null) return
//保存日志文件
saveCrashInfo2File(ex)
context.longToastOnUi(ex.msg)
context.longToastOnUi(ex.stackTraceStr)
Thread.sleep(3000)
}

@ -56,9 +56,8 @@ interface JsExtensions {
analyzeUrl.getStrResponseAwait().body
}.onFailure {
AppLog.put("ajax(${urlStr}) error\n${it.localizedMessage}", it)
it.printOnDebug()
}.getOrElse {
it.msg
it.stackTraceStr
}
}
}
@ -91,10 +90,9 @@ interface JsExtensions {
kotlin.runCatching {
analyzeUrl.getStrResponseAwait()
}.onFailure {
log("connect(${urlStr}) error\n${it.stackTraceToString()}")
it.printOnDebug()
AppLog.put("connect(${urlStr}) error\n${it.localizedMessage}", it)
}.getOrElse {
StrResponse(analyzeUrl.url, it.localizedMessage)
StrResponse(analyzeUrl.url, it.stackTraceStr)
}
}
}
@ -106,10 +104,9 @@ interface JsExtensions {
kotlin.runCatching {
analyzeUrl.getStrResponseAwait()
}.onFailure {
log("ajax($urlStr,$header) error\n${it.stackTraceToString()}")
it.printOnDebug()
AppLog.put("ajax($urlStr,$header) error\n${it.localizedMessage}", it)
}.getOrElse {
StrResponse(analyzeUrl.url, it.localizedMessage)
StrResponse(analyzeUrl.url, it.stackTraceStr)
}
}
}

@ -9,7 +9,7 @@ import io.legado.app.model.rss.Rss
import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.HtmlFormatter
import io.legado.app.utils.isAbsUrl
import io.legado.app.utils.msg
import io.legado.app.utils.stackTraceStr
import kotlinx.coroutines.CoroutineScope
import java.text.SimpleDateFormat
import java.util.*
@ -128,7 +128,7 @@ object Debug {
}
}
.onError {
log(debugSource, it.msg, state = -1)
log(debugSource, it.stackTraceStr, state = -1)
}
}
@ -145,7 +145,7 @@ object Debug {
log(debugSource, "︽内容页解析完成", state = 1000)
}
.onError {
log(debugSource, it.msg, state = -1)
log(debugSource, it.stackTraceStr, state = -1)
}
}
@ -204,7 +204,7 @@ object Debug {
}
}
.onError {
log(debugSource, it.msg, state = -1)
log(debugSource, it.stackTraceStr, state = -1)
}
tasks.add(explore)
}
@ -222,7 +222,7 @@ object Debug {
}
}
.onError {
log(debugSource, it.msg, state = -1)
log(debugSource, it.stackTraceStr, state = -1)
}
tasks.add(search)
}
@ -246,7 +246,7 @@ object Debug {
}
}
.onError {
log(debugSource, it.msg, state = -1)
log(debugSource, it.stackTraceStr, state = -1)
}
tasks.add(info)
}
@ -261,7 +261,7 @@ object Debug {
contentDebug(scope, bookSource, book, it.first(), nextChapterUrl)
}
.onError {
log(debugSource, it.msg, state = -1)
log(debugSource, it.stackTraceStr, state = -1)
}
tasks.add(chapterList)
}
@ -284,7 +284,7 @@ object Debug {
).onSuccess {
log(debugSource, "︽正文页解析完成", state = 1000)
}.onError {
log(debugSource, it.msg, state = -1)
log(debugSource, it.stackTraceStr, state = -1)
}
tasks.add(content)
}

@ -14,7 +14,7 @@ import io.legado.app.model.webBook.WebBook
import io.legado.app.service.BaseReadAloudService
import io.legado.app.ui.book.read.page.entities.TextChapter
import io.legado.app.ui.book.read.page.provider.ChapterProvider
import io.legado.app.utils.msg
import io.legado.app.utils.stackTraceStr
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.IO
@ -387,7 +387,7 @@ object ReadBook : CoroutineScope by MainScope() {
}
}.onError {
AppLog.put("ChapterProvider ERROR", it)
appCtx.toastOnUi("ChapterProvider ERROR:\n${it.msg}")
appCtx.toastOnUi("ChapterProvider ERROR:\n${it.stackTraceStr}")
}.onSuccess {
success?.invoke()
}

@ -667,7 +667,7 @@ class AnalyzeRule(
log("ajax(${urlStr}) error\n${it.stackTraceToString()}")
it.printOnDebug()
}.getOrElse {
it.msg
it.stackTraceStr
}
}
}

@ -9,8 +9,8 @@ import io.legado.app.data.appDb
import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.SearchBook
import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.msg
import io.legado.app.utils.printOnDebug
import io.legado.app.utils.stackTraceStr
import kotlinx.coroutines.Dispatchers.IO
@ -46,7 +46,7 @@ class ExploreShowViewModel(application: Application) : BaseViewModel(application
page++
}.onError {
it.printOnDebug()
errorLiveData.postValue(it.msg)
errorLiveData.postValue(it.stackTraceStr)
}
}
}

@ -254,11 +254,12 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
return@execute
}
}
throw NoStackTraceException("自动换源失败")
throw NoStackTraceException("没有搜索到 ${name}(${author})")
}.onStart {
ReadBook.upMsg(context.getString(R.string.source_auto_changing))
}.onError {
context.toastOnUi(it.msg)
AppLog.put("自动换源失败\n${it.localizedMessage}", it)
context.toastOnUi("自动换源失败\n${it.localizedMessage}")
}.onFinally {
ReadBook.upMsg(null)
}

@ -322,7 +322,7 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
importConfig(it)
}
}.onError {
longToast(it.msg)
longToast(it.stackTraceStr)
}
}

@ -128,7 +128,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
}.onSuccess {
success.invoke(it)
}.onError {
context.toastOnUi(it.msg)
context.toastOnUi(it.stackTraceStr)
}
}

@ -8,8 +8,8 @@ import io.legado.app.data.entities.RssSource
import io.legado.app.help.RuleComplete
import io.legado.app.help.http.CookieStore
import io.legado.app.utils.getClipText
import io.legado.app.utils.msg
import io.legado.app.utils.printOnDebug
import io.legado.app.utils.stackTraceStr
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers
@ -74,7 +74,7 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
finally.invoke(it)
}
}.onError {
context.toastOnUi(it.msg)
context.toastOnUi(it.stackTraceStr)
}
}

@ -83,7 +83,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
}.onSuccess {
success.invoke(it)
}.onError {
context.toastOnUi(it.msg)
context.toastOnUi(it.stackTraceStr)
}
}

@ -325,7 +325,7 @@ fun Context.openFileUri(uri: Uri, type: String? = null) {
try {
startActivity(intent)
} catch (e: Exception) {
toastOnUi(e.msg)
toastOnUi(e.stackTraceStr)
}
}

@ -2,7 +2,7 @@ package io.legado.app.utils
import java.io.IOException
val Throwable.msg: String
val Throwable.stackTraceStr: String
get() {
val stackTrace = stackTraceToString()
val lMsg = this.localizedMessage ?: "noErrorMsg"

Loading…
Cancel
Save