优化
This commit is contained in:
@@ -188,7 +188,7 @@ object BookController {
|
|||||||
}
|
}
|
||||||
returnData.setData(content)
|
returnData.setData(content)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
returnData.setErrorMsg(e.msg)
|
returnData.setErrorMsg(e.stackTraceStr)
|
||||||
}
|
}
|
||||||
return returnData
|
return returnData
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import io.legado.app.data.entities.ReplaceRule
|
|||||||
import io.legado.app.exception.RegexTimeoutException
|
import io.legado.app.exception.RegexTimeoutException
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
import io.legado.app.help.config.ReadBookConfig
|
import io.legado.app.help.config.ReadBookConfig
|
||||||
import io.legado.app.utils.msg
|
|
||||||
import io.legado.app.utils.replace
|
import io.legado.app.utils.replace
|
||||||
|
import io.legado.app.utils.stackTraceStr
|
||||||
import io.legado.app.utils.toastOnUi
|
import io.legado.app.utils.toastOnUi
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
@@ -149,7 +149,7 @@ class ContentProcessor private constructor(
|
|||||||
} catch (e: RegexTimeoutException) {
|
} catch (e: RegexTimeoutException) {
|
||||||
item.isEnabled = false
|
item.isEnabled = false
|
||||||
appDb.replaceRuleDao.update(item)
|
appDb.replaceRuleDao.update(item)
|
||||||
return item.name + e.msg
|
return item.name + e.stackTraceStr
|
||||||
} catch (e: CancellationException) {
|
} catch (e: CancellationException) {
|
||||||
return mContent
|
return mContent
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import io.legado.app.model.ReadAloud
|
|||||||
import io.legado.app.utils.FileUtils
|
import io.legado.app.utils.FileUtils
|
||||||
import io.legado.app.utils.getFile
|
import io.legado.app.utils.getFile
|
||||||
import io.legado.app.utils.longToastOnUi
|
import io.legado.app.utils.longToastOnUi
|
||||||
import io.legado.app.utils.msg
|
import io.legado.app.utils.stackTraceStr
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
import java.io.PrintWriter
|
import java.io.PrintWriter
|
||||||
import java.io.StringWriter
|
import java.io.StringWriter
|
||||||
@@ -48,7 +48,7 @@ class CrashHandler(val context: Context) : Thread.UncaughtExceptionHandler {
|
|||||||
if (ex == null) return
|
if (ex == null) return
|
||||||
//保存日志文件
|
//保存日志文件
|
||||||
saveCrashInfo2File(ex)
|
saveCrashInfo2File(ex)
|
||||||
context.longToastOnUi(ex.msg)
|
context.longToastOnUi(ex.stackTraceStr)
|
||||||
Thread.sleep(3000)
|
Thread.sleep(3000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,9 +56,8 @@ interface JsExtensions {
|
|||||||
analyzeUrl.getStrResponseAwait().body
|
analyzeUrl.getStrResponseAwait().body
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
AppLog.put("ajax(${urlStr}) error\n${it.localizedMessage}", it)
|
AppLog.put("ajax(${urlStr}) error\n${it.localizedMessage}", it)
|
||||||
it.printOnDebug()
|
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
it.msg
|
it.stackTraceStr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,10 +90,9 @@ interface JsExtensions {
|
|||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
analyzeUrl.getStrResponseAwait()
|
analyzeUrl.getStrResponseAwait()
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
log("connect(${urlStr}) error\n${it.stackTraceToString()}")
|
AppLog.put("connect(${urlStr}) error\n${it.localizedMessage}", it)
|
||||||
it.printOnDebug()
|
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
StrResponse(analyzeUrl.url, it.localizedMessage)
|
StrResponse(analyzeUrl.url, it.stackTraceStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,10 +104,9 @@ interface JsExtensions {
|
|||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
analyzeUrl.getStrResponseAwait()
|
analyzeUrl.getStrResponseAwait()
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
log("ajax($urlStr,$header) error\n${it.stackTraceToString()}")
|
AppLog.put("ajax($urlStr,$header) error\n${it.localizedMessage}", it)
|
||||||
it.printOnDebug()
|
|
||||||
}.getOrElse {
|
}.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.model.webBook.WebBook
|
||||||
import io.legado.app.utils.HtmlFormatter
|
import io.legado.app.utils.HtmlFormatter
|
||||||
import io.legado.app.utils.isAbsUrl
|
import io.legado.app.utils.isAbsUrl
|
||||||
import io.legado.app.utils.msg
|
import io.legado.app.utils.stackTraceStr
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -128,7 +128,7 @@ object Debug {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onError {
|
.onError {
|
||||||
log(debugSource, it.msg, state = -1)
|
log(debugSource, it.stackTraceStr, state = -1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ object Debug {
|
|||||||
log(debugSource, "︽内容页解析完成", state = 1000)
|
log(debugSource, "︽内容页解析完成", state = 1000)
|
||||||
}
|
}
|
||||||
.onError {
|
.onError {
|
||||||
log(debugSource, it.msg, state = -1)
|
log(debugSource, it.stackTraceStr, state = -1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ object Debug {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onError {
|
.onError {
|
||||||
log(debugSource, it.msg, state = -1)
|
log(debugSource, it.stackTraceStr, state = -1)
|
||||||
}
|
}
|
||||||
tasks.add(explore)
|
tasks.add(explore)
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,7 @@ object Debug {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onError {
|
.onError {
|
||||||
log(debugSource, it.msg, state = -1)
|
log(debugSource, it.stackTraceStr, state = -1)
|
||||||
}
|
}
|
||||||
tasks.add(search)
|
tasks.add(search)
|
||||||
}
|
}
|
||||||
@@ -246,7 +246,7 @@ object Debug {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onError {
|
.onError {
|
||||||
log(debugSource, it.msg, state = -1)
|
log(debugSource, it.stackTraceStr, state = -1)
|
||||||
}
|
}
|
||||||
tasks.add(info)
|
tasks.add(info)
|
||||||
}
|
}
|
||||||
@@ -261,7 +261,7 @@ object Debug {
|
|||||||
contentDebug(scope, bookSource, book, it.first(), nextChapterUrl)
|
contentDebug(scope, bookSource, book, it.first(), nextChapterUrl)
|
||||||
}
|
}
|
||||||
.onError {
|
.onError {
|
||||||
log(debugSource, it.msg, state = -1)
|
log(debugSource, it.stackTraceStr, state = -1)
|
||||||
}
|
}
|
||||||
tasks.add(chapterList)
|
tasks.add(chapterList)
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ object Debug {
|
|||||||
).onSuccess {
|
).onSuccess {
|
||||||
log(debugSource, "︽正文页解析完成", state = 1000)
|
log(debugSource, "︽正文页解析完成", state = 1000)
|
||||||
}.onError {
|
}.onError {
|
||||||
log(debugSource, it.msg, state = -1)
|
log(debugSource, it.stackTraceStr, state = -1)
|
||||||
}
|
}
|
||||||
tasks.add(content)
|
tasks.add(content)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import io.legado.app.model.webBook.WebBook
|
|||||||
import io.legado.app.service.BaseReadAloudService
|
import io.legado.app.service.BaseReadAloudService
|
||||||
import io.legado.app.ui.book.read.page.entities.TextChapter
|
import io.legado.app.ui.book.read.page.entities.TextChapter
|
||||||
import io.legado.app.ui.book.read.page.provider.ChapterProvider
|
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 io.legado.app.utils.toastOnUi
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
@@ -387,7 +387,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||||||
}
|
}
|
||||||
}.onError {
|
}.onError {
|
||||||
AppLog.put("ChapterProvider ERROR", it)
|
AppLog.put("ChapterProvider ERROR", it)
|
||||||
appCtx.toastOnUi("ChapterProvider ERROR:\n${it.msg}")
|
appCtx.toastOnUi("ChapterProvider ERROR:\n${it.stackTraceStr}")
|
||||||
}.onSuccess {
|
}.onSuccess {
|
||||||
success?.invoke()
|
success?.invoke()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -667,7 +667,7 @@ class AnalyzeRule(
|
|||||||
log("ajax(${urlStr}) error\n${it.stackTraceToString()}")
|
log("ajax(${urlStr}) error\n${it.stackTraceToString()}")
|
||||||
it.printOnDebug()
|
it.printOnDebug()
|
||||||
}.getOrElse {
|
}.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.BookSource
|
||||||
import io.legado.app.data.entities.SearchBook
|
import io.legado.app.data.entities.SearchBook
|
||||||
import io.legado.app.model.webBook.WebBook
|
import io.legado.app.model.webBook.WebBook
|
||||||
import io.legado.app.utils.msg
|
|
||||||
import io.legado.app.utils.printOnDebug
|
import io.legado.app.utils.printOnDebug
|
||||||
|
import io.legado.app.utils.stackTraceStr
|
||||||
|
|
||||||
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ class ExploreShowViewModel(application: Application) : BaseViewModel(application
|
|||||||
page++
|
page++
|
||||||
}.onError {
|
}.onError {
|
||||||
it.printOnDebug()
|
it.printOnDebug()
|
||||||
errorLiveData.postValue(it.msg)
|
errorLiveData.postValue(it.stackTraceStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,11 +254,12 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
return@execute
|
return@execute
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw NoStackTraceException("自动换源失败")
|
throw NoStackTraceException("没有搜索到 ${name}(${author})")
|
||||||
}.onStart {
|
}.onStart {
|
||||||
ReadBook.upMsg(context.getString(R.string.source_auto_changing))
|
ReadBook.upMsg(context.getString(R.string.source_auto_changing))
|
||||||
}.onError {
|
}.onError {
|
||||||
context.toastOnUi(it.msg)
|
AppLog.put("自动换源失败\n${it.localizedMessage}", it)
|
||||||
|
context.toastOnUi("自动换源失败\n${it.localizedMessage}")
|
||||||
}.onFinally {
|
}.onFinally {
|
||||||
ReadBook.upMsg(null)
|
ReadBook.upMsg(null)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
|
|||||||
importConfig(it)
|
importConfig(it)
|
||||||
}
|
}
|
||||||
}.onError {
|
}.onError {
|
||||||
longToast(it.msg)
|
longToast(it.stackTraceStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
|
|||||||
}.onSuccess {
|
}.onSuccess {
|
||||||
success.invoke(it)
|
success.invoke(it)
|
||||||
}.onError {
|
}.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.RuleComplete
|
||||||
import io.legado.app.help.http.CookieStore
|
import io.legado.app.help.http.CookieStore
|
||||||
import io.legado.app.utils.getClipText
|
import io.legado.app.utils.getClipText
|
||||||
import io.legado.app.utils.msg
|
|
||||||
import io.legado.app.utils.printOnDebug
|
import io.legado.app.utils.printOnDebug
|
||||||
|
import io.legado.app.utils.stackTraceStr
|
||||||
|
|
||||||
import io.legado.app.utils.toastOnUi
|
import io.legado.app.utils.toastOnUi
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -74,7 +74,7 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati
|
|||||||
finally.invoke(it)
|
finally.invoke(it)
|
||||||
}
|
}
|
||||||
}.onError {
|
}.onError {
|
||||||
context.toastOnUi(it.msg)
|
context.toastOnUi(it.stackTraceStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
|
|||||||
}.onSuccess {
|
}.onSuccess {
|
||||||
success.invoke(it)
|
success.invoke(it)
|
||||||
}.onError {
|
}.onError {
|
||||||
context.toastOnUi(it.msg)
|
context.toastOnUi(it.stackTraceStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ fun Context.openFileUri(uri: Uri, type: String? = null) {
|
|||||||
try {
|
try {
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
toastOnUi(e.msg)
|
toastOnUi(e.stackTraceStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.legado.app.utils
|
|||||||
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
val Throwable.msg: String
|
val Throwable.stackTraceStr: String
|
||||||
get() {
|
get() {
|
||||||
val stackTrace = stackTraceToString()
|
val stackTrace = stackTraceToString()
|
||||||
val lMsg = this.localizedMessage ?: "noErrorMsg"
|
val lMsg = this.localizedMessage ?: "noErrorMsg"
|
||||||
|
|||||||
Reference in New Issue
Block a user