Is there a way to deal with a method that ALWAYS raises? #2275
Unanswered
aaronmallen
asked this question in
Q&A
Replies: 1 comment
-
Sorbet has |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm unsure how to handle the situation where the outcome is either a thing or an error is raised. Specifically when the error is raised by a convenience method.
Take this example:
Obviously in this case the happy path is
check
returns abool
and I'd like the method to be typed as such to satisfy downstream dependencies. However steep doesn't like this at all. Steep will complain that you can't typecheck
asbool
because it potentially returnsvoid
.My guess is I need to somehow type
raise_invalid!
differently here but I'm not sure how to do that outside of doing something like this:Given the simplicity of my example this seems fine but in a more realistic scenario where I might have dozens of branches all of which potentially lead to
raise_invalid!
doing this would be cumbersome and ultimately reduce the reusability of the code.Beta Was this translation helpful? Give feedback.
All reactions