Panic less and with better messages #281

Unito
Plume_migration_agent ha unito 2 commit da panic-refactor a master 6 anni fa
trinity-1686a 6 anni fa ha commentato
Proprietario

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 (Migrato da github.com) hanno approvato queste modifiche 6 anni fa
elegaanz (Migrato da github.com) lascia un commento

Thanks a lot!

Thanks a lot!
elegaanz 6 anni fa ha commentato (Migrato da 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.
trinity-1686a 6 anni fa ha commentato
Autore
Proprietario

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 anni fa ha commentato (Migrato da 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…
trinity-1686a 6 anni fa ha commentato
Autore
Proprietario

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

Revisori

La pull request è stata unita come 879fde81ba.
Puoi anche visualizzare le istruzioni da riga di comando.

Passo 1:

Dal repository del tuo progetto, fai il check out di un nuovo branch e verifica le modifiche.
git checkout -b panic-refactor master
git pull origin panic-refactor

Passo 2:

Fai il merge delle modifiche e aggiorna su Forgejo.
git checkout master
git merge --no-ff panic-refactor
git push origin master
Effettua l'accesso per partecipare alla conversazione.
Nessun revisore
Nessuna milestone
Nessuna assegnatario
2 Partecipanti
Notifiche
Data di scadenza
La data di scadenza non è valida o fuori intervallo. Si prega di utilizzare il formato 'aaaa-mm-dd'.

Nessuna data di scadenza impostata.

Dipendenze

Nessuna dipendenza impostata.

Riferimento: Plume/Plume#281
Caricamento…
Non ci sono ancora contenuti.