Why does `ScopedValue.where(SCOPE_VALUE, val).call()` throw Exception?
Kasper Nielsen
kasperni at gmail.com
Thu Mar 23 19:46:29 UTC 2023
On Thu, 23 Mar 2023 at 16:32, Andrew Haley <aph-open at littlepinkcloud.com> wrote:
>
> What would supply() do? Just like call() but without an exception?
I know this is not the first (or last) discussion about functional
interfaces and checked exceptions.
But right now I'm using
try {
return ScopedValue.where(S, value, callable);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new UndeclaredThrowableException(e);
}
everywhere. Because whatever the methods my callables are delegating to does
not throw any checked exceptions.
On the other hand, I could see myself calling MethodHandle.invoke/invokeExact
(throws Throwable) within a scope. Having only Runnable/Callable forces
me to do any error-handling within the scope itself instead of outside
of the scope.
/Kasper
More information about the loom-dev
mailing list