From c1a9dd2e51dd7df6efd934b97a7e8eef3af15522 Mon Sep 17 00:00:00 2001 From: ryoii <ryoii@foxmail.com> Date: Wed, 26 Feb 2020 15:04:39 +0800 Subject: [PATCH] Fix: Http api response NoSuchElement(code 5) but expect NoBot(code 2) --- .../kotlin/net/mamoe/mirai/api/http/route/BaseRoute.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/BaseRoute.kt b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/BaseRoute.kt index 474095612..002bf0716 100644 --- a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/BaseRoute.kt +++ b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/BaseRoute.kt @@ -130,15 +130,15 @@ internal inline fun <reified T : VerifyDTO> Route.miraiVerify( internal inline fun Route.intercept(crossinline blk: suspend PipelineContext<Unit, ApplicationCall>.() -> Unit) = handle { try { blk(this) - } catch (e: IllegalSessionException) { + } catch (e: IllegalSessionException) { // Session过期 call.respondStateCode(StateCode.IllegalSession) - } catch (e: NotVerifiedSessionException) { + } catch (e: NotVerifiedSessionException) { // Session未认证 call.respondStateCode(StateCode.NotVerifySession) - } catch (e: NoSuchBotException) { + } catch (e: NoSuchBotException) { // Bot不存在 call.respondStateCode(StateCode.NoBot) - } catch (e: NoSuchElementException) { + } catch (e: NoSuchElementException) { // 指定对象不存在 call.respondStateCode(StateCode.NoElement) - } catch (e: PermissionDeniedException) { + } catch (e: PermissionDeniedException) { // 缺少权限 call.respondStateCode(StateCode.PermissionDenied) } catch (e: IllegalAccessException) { call.respondStateCode(StateCode(400, e.message), HttpStatusCode.BadRequest)