mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-09 18:00:33 +08:00
Fix: Http api response NoSuchElement(code 5) but expect NoBot(code 2)
This commit is contained in:
parent
c17361242b
commit
c1a9dd2e51
@ -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 {
|
internal inline fun Route.intercept(crossinline blk: suspend PipelineContext<Unit, ApplicationCall>.() -> Unit) = handle {
|
||||||
try {
|
try {
|
||||||
blk(this)
|
blk(this)
|
||||||
} catch (e: IllegalSessionException) {
|
} catch (e: IllegalSessionException) { // Session过期
|
||||||
call.respondStateCode(StateCode.IllegalSession)
|
call.respondStateCode(StateCode.IllegalSession)
|
||||||
} catch (e: NotVerifiedSessionException) {
|
} catch (e: NotVerifiedSessionException) { // Session未认证
|
||||||
call.respondStateCode(StateCode.NotVerifySession)
|
call.respondStateCode(StateCode.NotVerifySession)
|
||||||
} catch (e: NoSuchBotException) {
|
} catch (e: NoSuchBotException) { // Bot不存在
|
||||||
call.respondStateCode(StateCode.NoBot)
|
call.respondStateCode(StateCode.NoBot)
|
||||||
} catch (e: NoSuchElementException) {
|
} catch (e: NoSuchElementException) { // 指定对象不存在
|
||||||
call.respondStateCode(StateCode.NoElement)
|
call.respondStateCode(StateCode.NoElement)
|
||||||
} catch (e: PermissionDeniedException) {
|
} catch (e: PermissionDeniedException) { // 缺少权限
|
||||||
call.respondStateCode(StateCode.PermissionDenied)
|
call.respondStateCode(StateCode.PermissionDenied)
|
||||||
} catch (e: IllegalAccessException) {
|
} catch (e: IllegalAccessException) {
|
||||||
call.respondStateCode(StateCode(400, e.message), HttpStatusCode.BadRequest)
|
call.respondStateCode(StateCode(400, e.message), HttpStatusCode.BadRequest)
|
||||||
|
Loading…
Reference in New Issue
Block a user