优化错误提示

pull/768/head
gedoor 4 years ago
parent c02de3755f
commit dae57c4135
  1. 11
      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. 11
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt

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

@ -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 {
val analyzeUrl = AnalyzeUrl(urlStr, book = book)
runBlocking {
return runBlocking {
try {
val analyzeUrl = AnalyzeUrl(urlStr, book = book)
analyzeUrl.getStrResponse(urlStr).body
} catch (e: Exception) {
e.printStackTrace()
e.msg
}
} catch (e: Exception) {
e.localizedMessage
}
}

Loading…
Cancel
Save