-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
23 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...tp/src/main/kotlin/net/mamoe/mirai/api/http/adapter/http/plugin/GlobalExceptionHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2023 Mamoe Technologies and contributors. | ||
* | ||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. | ||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. | ||
* | ||
* https://github.com/mamoe/mirai/blob/master/LICENSE | ||
*/ | ||
|
||
package net.mamoe.mirai.api.http.adapter.http.plugin | ||
|
||
import io.ktor.server.application.* | ||
import io.ktor.server.application.hooks.* | ||
import net.mamoe.mirai.api.http.adapter.http.router.respondStateCode | ||
import net.mamoe.mirai.api.http.adapter.internal.handler.toStateCode | ||
|
||
val GlobalExceptionHandler = createApplicationPlugin("GlobalExceptionHandler") { | ||
on(CallFailed) { call, cause -> | ||
call.respondStateCode(cause.toStateCode()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters