limbang / mirai-console-mcmod-plugin

基于 Mirai Console 编写的MC百科搜索插件
GNU Affero General Public License v3.0
39 stars 3 forks source link

查询超时时建议返回超时信息 #24

Closed sxjeru closed 2 years ago

sxjeru commented 2 years ago

比如百科站挂掉时查询信息,后台会报以下错误,但聊天区无任何回应。 建议能返回一句“查询超时,请……”

2022-03-06 09:26:37 E/top.limbang.mirai-console-mcmod-plugin: Exception in coroutine Plugin top.limbang.mirai-console-mcmod-plugin of top.limbang.mirai-console-mcmod-plugin
java.net.SocketTimeoutException: timeout
        at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.kt:677)
        at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.kt:686)
        at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.kt:143)
        at okhttp3.internal.http2.Http2ExchangeCodec.readResponseHeaders(Http2ExchangeCodec.kt:96)
        at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:106)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at top.limbang.mirai.mcmod.service.AgentInterceptor.intercept(HttpUtil.kt:81)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
        at top.limbang.mirai.mcmod.service.HttpUtil.get(HttpUtil.kt:33)
        at top.limbang.mirai.mcmod.service.HttpUtil.getDocument(HttpUtil.kt:47)
        at top.limbang.mirai.mcmod.service.MinecraftMod.search(MinecraftMod.kt:158)
        at top.limbang.mirai.mcmod.service.MinecraftMod.search(MinecraftMod.kt:36)
        at top.limbang.mirai.mcmod.service.MinecraftModService.search(MinecraftModService.kt:17)
        at top.limbang.mirai.mcmod.service.MinecraftModService.getSearchList(MinecraftModService.kt:23)
        at top.limbang.mirai.mcmod.MiraiConsoleMcmodPlugin$onEnable$1$1.invokeSuspend(MiraiConsoleMcmodPlugin.kt:68)
        at top.limbang.mirai.mcmod.MiraiConsoleMcmodPlugin$onEnable$1$1.invoke(MiraiConsoleMcmodPlugin.kt)
        at top.limbang.mirai.mcmod.MiraiConsoleMcmodPlugin$onEnable$1$1.invoke(MiraiConsoleMcmodPlugin.kt)
        at net.mamoe.mirai.event.MessageSubscribersBuilder$reply$3.invokeSuspend(MessageSubscribersBuilder.kt:510)
        at net.mamoe.mirai.event.MessageSubscribersBuilder$reply$3.invoke(MessageSubscribersBuilder.kt)
        at net.mamoe.mirai.event.MessageSubscribersBuilder$reply$3.invoke(MessageSubscribersBuilder.kt)
        at net.mamoe.mirai.internal.event.MessageSubscribersInternalKt$content$1.invokeSuspend(messageSubscribersInternal.kt:27)
        at net.mamoe.mirai.internal.event.MessageSubscribersInternalKt$content$1.invoke(messageSubscribersInternal.kt)
        at net.mamoe.mirai.internal.event.MessageSubscribersInternalKt$content$1.invoke(messageSubscribersInternal.kt)
        at net.mamoe.mirai.event.SubscribeMessagesKt__SubscribeMessagesKt$subscribeMessages$$inlined$createBuilder$SubscribeMessagesKt__SubscribeMessagesKt$1$1.invokeSuspend(subscribeMessages.kt:253)
        at net.mamoe.mirai.event.SubscribeMessagesKt__SubscribeMessagesKt$subscribeMessages$$inlined$createBuilder$SubscribeMessagesKt__SubscribeMessagesKt$1$1.invoke(subscribeMessages.kt)
        at net.mamoe.mirai.event.SubscribeMessagesKt__SubscribeMessagesKt$subscribeMessages$$inlined$createBuilder$SubscribeMessagesKt__SubscribeMessagesKt$1$1.invoke(subscribeMessages.kt)
        at net.mamoe.mirai.event.EventChannel$subscribeAlways$1.invokeSuspend(EventChannel.kt:455)
        at net.mamoe.mirai.event.EventChannel$subscribeAlways$1.invoke(EventChannel.kt)
        at net.mamoe.mirai.event.EventChannel$subscribeAlways$1.invoke(EventChannel.kt)
        at net.mamoe.mirai.internal.event.Handler$onEvent$2.invokeSuspend(InternalEventListeners.kt:50)
        at net.mamoe.mirai.internal.event.Handler$onEvent$2.invoke(InternalEventListeners.kt)
        at net.mamoe.mirai.internal.event.Handler$onEvent$2.invoke(InternalEventListeners.kt)
        at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:165)
        at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
        at net.mamoe.mirai.internal.event.Handler.onEvent(InternalEventListeners.kt:50)
        at net.mamoe.mirai.internal.event.InternalEventListenersKt.process(InternalEventListeners.kt:166)
        at net.mamoe.mirai.internal.event.InternalEventListenersKt.access$process(InternalEventListeners.kt:1)
        at net.mamoe.mirai.internal.event.InternalEventListenersKt$callAndRemoveIfRequired$2$1.invokeSuspend(InternalEventListeners.kt:132)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
sxjeru commented 2 years ago

此外即便百科站已挂,用插件搜索“ic2”等关键词时,后台也不会报超时错误,前台聊天区只得到“未搜索到结果,请更换关键字重试”一句。

limbang commented 2 years ago

可以的。找个机会重构下

limbang commented 2 years ago

最新版本已经支持