-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make BindException public #96
Comments
Could you paste the example code in which you managed to catch it? It definitely shouldn't leak from the call to Generally I would not consider the |
): Result<Unit, InvocationError> = binding {
...
val result = runCatching { // runCatching will catch the inner bind as it catches throwable
instructions.forEach { instruction ->
instructionExecutor(instruction, store, stack).bind()
}
}
So this wouldn't be a problem if I could do this result.onFailure { err ->
// todo rethrow bind exception
if(err is BindException) throw err
if (err is BreakException) {
...
}
if (err is ReturnException) {
...
} I'm mixing exceptions and errors here intentionally, I understand this isn't how you typically program with result but its essential in my use case |
So fundamentally the problem resides in the fact that all calls to If my explanation above is correct then I think I am generally happy with the way things are currently and wouldn't be looking to make the The fact that
If you'd like to provide a more full-fledged example I'm sure I can help you rewrite it to avoid this case. As it stands the inclusion of a call to |
I appreciate I have a very unique scenario, I'm building an interpreter and I'm forced to use Exceptions when modelling branching (breaking and returning), so I wanted to mix and match. If you're happy with your api design thats no problem, what I can do is just not throw bind inside the runCatching lambda and manually wire the result |
Hi @CharlieTap. I did some thinking about the use case that you've hit, and I have an idea (to make Please can you have a look this test case and tell me what you are doing differently? For me the |
As BindException can be thrown its possible for a another try block to catch it so technically it's part of the API. I actually discovered this because of bug where I was accidentally catching it and then I was unable to write a condition to specifically rethrow it because its marked internal 😬
The text was updated successfully, but these errors were encountered: