Skip to content

Conversation

@liweinan
Copy link
Contributor

No description provided.

- 将配置项函数改为返回Result,避免使用不合理的默认值
- 修复htycommons模块中的unwrap调用,使用unwrap_or、unwrap_or_else或?操作符
- 修复htyuc模块中的unwrap调用
- 修复htyuc_models模块中的unwrap调用
- 修复所有构建错误,确保项目可以成功编译
- 修复db.rs中POOL_SIZE解析的错误处理
- 使用unwrap_or_else直接格式化错误消息,避免冗余的map_err转换
- 修复raw_find_all_tags、raw_register_verify、raw_update_hty_gonggao等函数
- 修复update_tongzhi_status_by_id、raw_update_official_account_openid等函数
- 修复raw_register_rollback、raw_register中的unionid和openid处理
- 修复raw_update_user_group、raw_create_user_group函数
- 修复raw_update_template_data、raw_update_template、raw_create_template_data等函数
- 修复raw_create_or_update_userinfo_with_roles、verify_username等函数
- 修复raw_create_or_update_apps_with_roles、raw_create_or_update_roles等函数
- 使用ok_or_else和match模式替换unwrap,提供更清晰的错误信息
- htyuc/src/lib.rs: 修复raw_find_user_with_info_by_token、raw_sudo2、wx_qr_login、raw_login2_with_unionid等函数中的unwrap()调用
- htyuc_models/src/wx.rs: 修复微信相关函数中的unwrap()调用,包括get_or_save_wx_access_token、fn_get_jsapi_ticket、push_wx_message等
- 使用ok_or_else、if let、match等安全错误处理方式替代unwrap()
- htyuc/src/ddl.rs: 修复generate_cert_key_pair和UserAppInfo查找中的unwrap()调用
- htyuc/src/notifications.rs: 修复所有微信推送消息构建函数中的unwrap()调用
- htyuc_models/src/models.rs: 修复大量模型转换和查询函数中的unwrap()调用
- htyuc_models/src/wx.rs: 修复create_with_info_with_tx和serde_json::to_string的调用
- htyuc_remote/src/remote_calls.rs: 修复app_id、app_status和user_infos的unwrap()调用
- upyun_tool/src/upyun.rs: 修复path.file_name()的unwrap()调用
- 使用ok_or_else、if let、match、expect等安全错误处理方式替代unwrap()
}),
})
.unwrap()
.unwrap_or_else(|_| "{\"r\":false,\"d\":null,\"e\":\"AuthorizationErr\",\"hty_err\":{\"code\":\"InternalErr\",\"reason\":null}}".to_string())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该用已有结构或者方法构建,而不是手工组成string.

}),
})
.unwrap()
.unwrap_or_else(|_| "{\"r\":false,\"d\":null,\"e\":\"HtySudoerTokenErr\",\"hty_err\":{\"code\":\"AuthenticationFailed\",\"reason\":\"HtySudoerTokenErr\"}}".to_string())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该用已有结构或者方法构建,而不是手工组成string.

htyuc/src/lib.rs Outdated
let in_user = HtyUser::find_by_hty_id(
&token.hty_id.clone().unwrap()[..],
&hty_id[..],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里可以不需要使用切片

- htycommons/src/web.rs: wrap_auth_err和wrap_sudo_err使用HtyResponse结构体构建,移除手工JSON字符串
- htyuc/src/lib.rs: 移除不必要的切片操作,直接使用&hty_id而不是&hty_id[..]
@liweinan liweinan merged commit 75de23d into alchemy-studio:master Nov 22, 2025
1 check passed
@liweinan liweinan linked an issue Nov 22, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

清理所有的unwrap()

1 participant