Panic less and with better messages #281

已合并
Plume_migration_agent 6 年前 将 2 次代码提交从 panic-refactor 合并至 master
所有者

Fix #21
Change most unwrap to expect, and don't panic when it can be avoided. Also return better http codes, i.e. 400 and 404, when appropriate.
The trait rocker::request::FromParam should probably be implemented for Post, Blog, Media, User and Tag. Then we wouldn't need to return Options whenever an entity does not exist, and just let Rocket do the work for us

Fix #21 Change most unwrap to expect, and don't panic when it can be avoided. Also return better http codes, i.e. 400 and 404, when appropriate. The trait `rocker::request::FromParam` should probably be implemented for Post, Blog, Media, User and Tag. Then we wouldn't need to return `Option`s whenever an entity does not exist, and just let Rocket do the work for us
elegaanz (从 github.com 迁移)6 年前 批准此合并请求
elegaanz (从 github.com 迁移) 留下了一条评论

Thanks a lot!

Thanks a lot!
elegaanz 评论于 6 年前 (从 github.com 迁移)

And yes, implementing FromParams for these types would be a good idea.

And yes, implementing FromParams for these types would be a good idea.
发布者
所有者

After trying to, I guess it might not be possible, because we need a db connection, and I don't think there is a way to access managed state from from_param (it only takes a &RawStr as parameters). Nonetheless I'll ask on Matrix

After trying to, I guess it might not be possible, because we need a db connection, and I don't think there is a way to access managed state from from_param (it only takes a &RawStr as parameters). Nonetheless I'll ask on Matrix
elegaanz 评论于 6 年前 (从 github.com 迁移)

Maybe with with FromRequest and Request::get_param then? But it may force us to duplicate parameters in the routes signatures…

Maybe with with `FromRequest` and `Request::get_param` then? But it may force us to duplicate parameters in the routes signatures…
发布者
所有者

If we end up doing manual routing it may reduce code duplication a bit, but it will add a lot of complexity, and we won't be able to use rocket's code generation if we do so. I'll see what answer I get from Matrix, but what I said earlier might very well be a false good idea

If we end up doing manual routing it may reduce code duplication a bit, but it will add a lot of complexity, and we won't be able to use rocket's code generation if we do so. I'll see what answer I get from Matrix, but what I said earlier might very well be a false good idea

评审人

该合并请求已作为 879fde81ba 被合并。
你也可以查看 命令行指令

第一步:

从你的仓库中签出一个新的分支并测试变更。
git checkout -b panic-refactor master
git pull origin panic-refactor

第二步:

合并变更并更新到 Forgejo 上
git checkout master
git merge --no-ff panic-refactor
git push origin master
登录 并参与到对话中。
无审核者
未选择里程碑
未指派成员
2 名参与者
通知
到期时间
到期日期无效或超出范围。请使用 'yyyy-mm-dd' 格式。

未设置到期时间。

依赖工单

没有设置依赖项。

参考:Plume/Plume#281
正在加载...
这个人很懒,什么都没留下。