[core] Ensure Bot.login always show actual login cause whenever a failure in Bot.close happens

This commit is contained in:
Him188 2022-12-27 17:29:26 +00:00
parent 2252683cee
commit 04b16fe2e4
No known key found for this signature in database
GPG Key ID: BA439CDDCF652375

View File

@ -146,11 +146,16 @@ internal abstract class AbstractBot constructor(
e.unwrapForPublicApi()
} else e
// close bot if it hadn't been done during `resumeConnection()`
if (!components[SsoProcessor].firstLoginSucceed) {
close(cause) // failed to do first login, close bot
} else if (cause is LoginFailedException && cause.killBot) {
close(cause) // re-login failed and has caused bot being somehow killed by server
try {
// close bot if it hadn't been done during `resumeConnection()`
if (!components[SsoProcessor].firstLoginSucceed) {
close(cause) // failed to do first login, close bot
} else if (cause is LoginFailedException && cause.killBot) {
close(cause) // re-login failed and has caused bot being somehow killed by server
}
} catch (errorInClose: Throwable) {
errorInClose.addSuppressed(cause)
throw errorInClose
}
throw cause