🐛 Correct Order of Exception Clauses

Resolves PYL-E0701: Bad except clauses order (ValueError is an ancestor class of UnicodeEncodeError)
This commit is contained in:
洛水居室 2023-11-16 14:09:54 +08:00
parent ac4610a57c
commit 7cdc453a22
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC

View File

@ -248,14 +248,14 @@ class AccountCookiesPlugin(Plugin.Conversation):
logger.warning("用户 %s[%s] 获取账号信息发生错误 [%s]%s", user.full_name, user.id, exc.ret_code, exc.original) logger.warning("用户 %s[%s] 获取账号信息发生错误 [%s]%s", user.full_name, user.id, exc.ret_code, exc.original)
await message.reply_text("Stoken 无效,请重新绑定。", reply_markup=ReplyKeyboardRemove()) await message.reply_text("Stoken 无效,请重新绑定。", reply_markup=ReplyKeyboardRemove())
return ConversationHandler.END return ConversationHandler.END
except UnicodeEncodeError:
await message.reply_text("Stoken 非法,请重新绑定。", reply_markup=ReplyKeyboardRemove())
return ConversationHandler.END
except ValueError as e: except ValueError as e:
if "account_id" in str(e): if "account_id" in str(e):
await message.reply_text("account_id 未找到,请检查输入是否有误。") await message.reply_text("account_id 未找到,请检查输入是否有误。")
return ConversationHandler.END return ConversationHandler.END
raise e raise e
except UnicodeEncodeError:
await message.reply_text("Stoken 非法,请重新绑定。", reply_markup=ReplyKeyboardRemove())
return ConversationHandler.END
try: try:
if cookies.account_id is None: if cookies.account_id is None:
logger.info("正在尝试获取用户 %s[%s] account_id", user.full_name, user.id) logger.info("正在尝试获取用户 %s[%s] account_id", user.full_name, user.id)