mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-21 10:14:42 +08:00
Use collectThrow
instead of throw
in SsoProcessor.SlowLoginImpl.login
This commit is contained in:
parent
756c805460
commit
679e61e4d0
@ -229,7 +229,7 @@ internal class SsoProcessorImpl(
|
|||||||
val ticket = try {
|
val ticket = try {
|
||||||
loginSolverNotNull().onSolveSliderCaptcha(bot, response.url)?.takeIf { it.isNotEmpty() }
|
loginSolverNotNull().onSolveSliderCaptcha(bot, response.url)?.takeIf { it.isNotEmpty() }
|
||||||
} catch (e: LoginFailedException) {
|
} catch (e: LoginFailedException) {
|
||||||
throw e
|
collectThrow(e)
|
||||||
} catch (error: Throwable) {
|
} catch (error: Throwable) {
|
||||||
if (allowSlider) {
|
if (allowSlider) {
|
||||||
collectException(error)
|
collectException(error)
|
||||||
@ -237,7 +237,7 @@ internal class SsoProcessorImpl(
|
|||||||
response = WtLogin9(client, allowSlider).sendAndExpect()
|
response = WtLogin9(client, allowSlider).sendAndExpect()
|
||||||
continue@mainloop
|
continue@mainloop
|
||||||
}
|
}
|
||||||
throw error
|
collectThrow(error)
|
||||||
}
|
}
|
||||||
response = if (ticket == null) {
|
response = if (ticket == null) {
|
||||||
WtLogin9(client, allowSlider).sendAndExpect()
|
WtLogin9(client, allowSlider).sendAndExpect()
|
||||||
@ -246,7 +246,7 @@ internal class SsoProcessorImpl(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// retry once
|
// retry once
|
||||||
if (!allowSlider) throw createUnsupportedSliderCaptchaException(allowSlider)
|
if (!allowSlider) collectThrow(createUnsupportedSliderCaptchaException(allowSlider))
|
||||||
allowSlider = false
|
allowSlider = false
|
||||||
response = WtLogin9(client, allowSlider).sendAndExpect()
|
response = WtLogin9(client, allowSlider).sendAndExpect()
|
||||||
}
|
}
|
||||||
@ -254,21 +254,21 @@ internal class SsoProcessorImpl(
|
|||||||
|
|
||||||
is LoginPacketResponse.Error -> {
|
is LoginPacketResponse.Error -> {
|
||||||
if (response.message.contains("0x9a")) { //Error(title=登录失败, message=请你稍后重试。(0x9a), errorInfo=)
|
if (response.message.contains("0x9a")) { //Error(title=登录失败, message=请你稍后重试。(0x9a), errorInfo=)
|
||||||
throw RetryLaterException().initCause(IllegalStateException("Login failed: $response"))
|
collectThrow(RetryLaterException().initCause(IllegalStateException("Login failed: $response")))
|
||||||
}
|
}
|
||||||
val msg = response.toString()
|
val msg = response.toString()
|
||||||
throw WrongPasswordException(buildString(capacity = msg.length) {
|
collectThrow(WrongPasswordException(buildString(capacity = msg.length) {
|
||||||
append(msg)
|
append(msg)
|
||||||
if (msg.contains("当前上网环境异常")) { // Error(title=禁止登录, message=当前上网环境异常,请更换网络环境或在常用设备上登录或稍后再试。, errorInfo=)
|
if (msg.contains("当前上网环境异常")) { // Error(title=禁止登录, message=当前上网环境异常,请更换网络环境或在常用设备上登录或稍后再试。, errorInfo=)
|
||||||
append(", tips=若频繁出现, 请尝试开启设备锁")
|
append(", tips=若频繁出现, 请尝试开启设备锁")
|
||||||
}
|
}
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
is LoginPacketResponse.SMSVerifyCodeNeeded -> {
|
is LoginPacketResponse.SMSVerifyCodeNeeded -> {
|
||||||
val message = "SMS required: $response, which isn't yet supported"
|
val message = "SMS required: $response, which isn't yet supported"
|
||||||
logger.error(message)
|
logger.error(message)
|
||||||
throw UnsupportedSMSLoginException(message)
|
collectThrow(UnsupportedSMSLoginException(message))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user