Panic less and with better messages #281

Fusionnée
Plume_migration_agent a fusionné 2 révision(s) à partir de panic-refactor vers master 2018-10-20 09:56:30 +00:00
Propriétaire

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 (Migré de github.com) a approuvé ces modifications 2018-10-20 09:55:17 +00:00
elegaanz (Migré de github.com) a laissé un commentaire

Thanks a lot!

Thanks a lot!
elegaanz a commenté 2018-10-20 09:56:24 +00:00. (Migré de 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.
Auteur
Propriétaire

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 a commenté 2018-10-20 11:24:58 +00:00. (Migré de 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…
Auteur
Propriétaire

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
Connectez-vous pour rejoindre cette conversation.
Sans évaluateur
Sans jalon
Sans projet
Sans assignation
2 participants
Notifications
Échéance
La date d’échéance est invalide ou hors plage. Veuillez utiliser le format "aaaa-mm-dd".

Aucune échéance n'a été définie.

Dépendances

Aucune dépendance définie.

Référence : Plume/Plume#281
Sans contenu.