Skip to content

Commit 3d39896

Browse files
committed
docs: clarify exception handling logic
1 parent 53b2383 commit 3d39896

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

saltify-docs/content/quick-tour.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ val myPlugin = createSaltifyPlugin("test") {
145145
// ...
146146
}
147147

148-
// 使用 Typed error 处理命令参数类型不匹配,命令参数缺失等情况
148+
// 使用 Typed error 处理命令参数类型不匹配,命令参数缺失等情况
149149
onFailure {
150150
respond {
151151
text("Command run failed: $it")
@@ -169,7 +169,8 @@ val client = SaltifyApplication {
169169

170170
## 异常处理
171171

172-
`SaltifyApplication` 会将插件和事件监听器中的异常通过 `exceptionFlow` 抛出。默认情况下,应用级别的异常会被重新抛出,而组件级别的异常会被捕获并打印到控制台。你也可以通过收集 `exceptionFlow` 来实现自定义的异常处理逻辑:
172+
`SaltifyApplication` 会将插件和事件监听器中的异常通过 `exceptionFlow` 抛出。默认情况下,所有异常都会被无视。
173+
你可以收集 (通常来说是必须) `exceptionFlow` 来实现自定义逻辑。
173174

174175
```kotlin
175176
launch {
@@ -178,9 +179,9 @@ launch {
178179

179180
when (component.type) {
180181
SaltifyComponentType.Application -> throw exception
181-
else -> println(
182-
"Component ${component.name}(${component.type}) occurred an exception: " +
183-
exception.stackTraceToString()
182+
else -> logger.error(
183+
"Saltify component ${component.name}(${component.type}) occurred an exception: ",
184+
exception
184185
)
185186
}
186187
}

0 commit comments

Comments
 (0)