优化错误提示

pull/768/head
gedoor 4 years ago
parent c02de3755f
commit dae57c4135
  1. 7
      app/src/main/java/io/legado/app/help/JsExtensions.kt
  2. 2
      app/src/main/java/io/legado/app/help/http/parser/TextParser.kt
  3. 9
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt

@ -29,15 +29,16 @@ interface JsExtensions {
* 访问网络,返回String
*/
fun ajax(urlStr: String): String? {
return try {
return runBlocking {
try {
val analyzeUrl = AnalyzeUrl(urlStr)
runBlocking {
analyzeUrl.getStrResponse(urlStr).body
}
} catch (e: Exception) {
e.printStackTrace()
e.msg
}
}
}
/**
* 访问网络,返回Response<String>

@ -8,7 +8,7 @@ import rxhttp.wrapper.exception.HttpStatusCodeException
import java.nio.charset.Charset
@Parser(name = "Text")
class TextParser(val encode: String? = null) : rxhttp.wrapper.parse.Parser<String> {
class TextParser(private val encode: String? = null) : rxhttp.wrapper.parse.Parser<String> {
override fun onParse(response: Response): String {

@ -653,13 +653,14 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions {
* js实现跨域访问,不能删
*/
override fun ajax(urlStr: String): String? {
return try {
return runBlocking {
try {
val analyzeUrl = AnalyzeUrl(urlStr, book = book)
runBlocking {
analyzeUrl.getStrResponse(urlStr).body
}
} catch (e: Exception) {
e.localizedMessage
e.printStackTrace()
e.msg
}
}
}

Loading…
Cancel
Save