pylodon icon indicating copy to clipboard operation
pylodon copied to clipboard

Abort a request if the user is not found

Open AstraLuma opened this issue 5 years ago • 4 comments

This is probably totally the wrong thing to do. But it seems better than throwing 500's?

AstraLuma avatar Aug 28 '18 23:08 AstraLuma

Ooh, good point. I'm feeling torn right now about whether the find_user function should do the abort, or whether everything implementing find_user should try catch -- I'm not super fond of side effects where I can avoid them, y'know?

I think that I want to stick with find_user always returning a user-type-thing, whether that's the user object or None (or potentially some other option), but I'm definitely open to changing my mind on that

rowanlupton avatar Aug 29 '18 23:08 rowanlupton

Well, this was a quick hack, and I can certainly see cases where you want to look up a user and handle it differently.

AstraLuma avatar Aug 30 '18 21:08 AstraLuma

I will say that some ORMs handle it by raising an exception (eg, Django's ORM raises an ObjectDoesNotExist)

AstraLuma avatar Aug 30 '18 21:08 AstraLuma

yeah i hear you! i think that an exception is probably the way to go? i'll mull it over some more

rowanlupton avatar Aug 31 '18 14:08 rowanlupton