Why does `ScopedValue.where(SCOPE_VALUE, val).call()` throw Exception?
Andrew Haley
aph-open at littlepinkcloud.com
Thu Mar 23 16:31:10 UTC 2023
On 3/23/23 11:16, Kasper Nielsen wrote:
> I'm in a similar situation as Josiah.
>
> It was the first thing I noticed when using ScopedValue.
> Why do I have to handle an exception when the code I'm calling
> does not throw any checked exceptions?
>
> So I would really like something like
> <R> R supply(Supplier<? extends R> op);
> on ScopedValue.Carrier
>
> and maybe rearrange Carrier to
> void where(ScopedValue<T> key, T value, Runnable op);
> R where(ScopedValue<T> key, T value, Supplier<? extends R> op);
A function from Exception -> R is more useful than a plain Supplier
because the handler might need to know what kind of Exception was
thrown.
> R whereChecked(ScopedValue<T> key, T value, Callable<? extends R> op) throws Exception;
--
Andrew Haley (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the loom-dev
mailing list