Closed iluuu1994 closed 3 years ago
I wouldn't do 2.
- often enough your inputs come from a trusted source, it's good to have a hard failure there instead of passing null around.
Adding has
is fine.
@Crell I'm ok with option 1 if you are.
I'd favor 1. Forcing the user to check for null every time to avoid random nulls elsewhere is a bad idea.
has-and-exception it is.
Not yet specified in the RFC. @Crell Can you do that?
Added has()
.
Should we throw a more specific error for a missing case than just ValueError
? Something more easily catchable, like EnumCaseNotFoundError
, which includes the bad value that was requested?
I feel like ValueError
is appropriate - don't catch, use has()
would be my philosophy. Better for the ecosystem if there are not multiple obvious ways to do the same thing.
I think ValueError
works fine, since that is the only exception thrown by this functions. Thanks!
Some people have suggested either
has
method to know iffrom
will succeedfrom
returnnull
insteadI'm not super happy with either of those but we'll probably have to settle for one of them. @Crell Which do you prefer?
/cc @bwoebi