Panic less and with better messages #281

Merge aplicado
Plume_migration_agent aplicou merge dos 2 commits de panic-refactor em master 6 anos atrás
Proprietário

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 (Migrado de github.com) aprovou estas alterações 6 anos atrás
elegaanz (Migrado de github.com) deixou um comentário

Thanks a lot!

Thanks a lot!
elegaanz comentou 6 anos atrás (Migrado 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.
Autor
Proprietário

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 comentou 6 anos atrás (Migrado 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…
Autor
Proprietário

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

Revisores

O pull request teve merge aplicado como 879fde81ba.
Você também pode ver as instruções para a linha de comandos.

Passo 1:

No repositório do seu projeto, crie um novo branch e teste as alterações.
git checkout -b panic-refactor master
git pull origin panic-refactor

Passo 2:

Faça merge das alterações e atualize no Forgejo.
git checkout master
git merge --no-ff panic-refactor
git push origin master
Acesse para participar desta conversação.
Sem revisor
Sem marco
Sem responsável
2 participante(s)
Notificações
Data limite
A data limite é inválida ou está fora do intervalo. Por favor, use o formato 'dd/mm/aaaa'.

Data limite não informada.

Dependências

Nenhuma dependência definida.

Referência: Plume/Plume#281
Carregando…
Ainda não há conteúdo.