<div dir="auto"><div>I guess to me it's not apparent that an operation that uses a scoped value must necessarily throw a checked exception that must be handled. <br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 23, 2023, 12:31 PM Andrew Haley <<a href="mailto:aph-open@littlepinkcloud.com" rel="noreferrer noreferrer noreferrer" target="_blank">aph-open@littlepinkcloud.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 3/23/23 11:16, Kasper Nielsen wrote:<br>
> I'm in a similar situation as Josiah.<br>
> <br>
> It was the first thing I noticed when using ScopedValue.<br>
> Why do I have to handle an exception when the code I'm calling<br>
> does not throw any checked exceptions?<br>
> <br>
> So I would really like something like<br>
>   <R> R supply(Supplier<? extends R> op);<br>
> on ScopedValue.Carrier<br>
> <br>
> and maybe rearrange Carrier to<br>
> void where(ScopedValue<T> key, T value, Runnable op);<br>
> R where(ScopedValue<T> key, T value, Supplier<? extends R> op);<br>
<br>
A function from Exception -> R is more useful than a plain Supplier<br>
because the handler might need to know what kind of Exception was<br>
thrown.<br>
<br>
> R whereChecked(ScopedValue<T> key, T value, Callable<? extends R> op) throws Exception;<br>
<br>
-- <br>
Andrew Haley  (he/him)<br>
Java Platform Lead Engineer<br>
Red Hat UK Ltd. <<a href="https://www.redhat.com" rel="noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">https://www.redhat.com</a>><br>
<a href="https://keybase.io/andrewhaley" rel="noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">https://keybase.io/andrewhaley</a><br>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671<br>
<br>
</blockquote></div></div></div>