diff --git a/app/src/main/java/io/legado/app/constant/AppLog.kt b/app/src/main/java/io/legado/app/constant/AppLog.kt index a9db5d848..8a175fb2a 100644 --- a/app/src/main/java/io/legado/app/constant/AppLog.kt +++ b/app/src/main/java/io/legado/app/constant/AppLog.kt @@ -5,7 +5,7 @@ object AppLog { val logs = arrayListOf>() @Synchronized - fun addLog(message: String?, throwable: Throwable?) { + fun addLog(message: String?, throwable: Throwable? = null) { message ?: return if (logs.size > 100) { logs.removeLastOrNull() diff --git a/app/src/main/java/io/legado/app/ui/document/HandleFileViewModel.kt b/app/src/main/java/io/legado/app/ui/document/HandleFileViewModel.kt index 71168e333..37fb436f8 100644 --- a/app/src/main/java/io/legado/app/ui/document/HandleFileViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/document/HandleFileViewModel.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.constant.AppLog import io.legado.app.help.DirectLinkUpload import io.legado.app.utils.FileUtils import io.legado.app.utils.isContentScheme @@ -27,6 +28,7 @@ class HandleFileViewModel(application: Application) : BaseViewModel(application) }.onSuccess { success.invoke(it) }.onError { + AppLog.addLog("上传文件失败\n${it.localizedMessage}", it) it.printOnDebug() errorLiveData.postValue(it.localizedMessage) }