Why does `ScopedValue.where(SCOPE_VALUE, val).call()` throw Exception?
Andrew Haley
aph-open at littlepinkcloud.com
Fri Mar 24 09:59:10 UTC 2023
On 3/23/23 19:46, Kasper Nielsen wrote:
> 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);
> }
Surely you could write something like
public static <T> T call(ScopedValue.Carrier aCarrier, Callable<T> aCallable) {
try {
return aCarrier.call(aCallable);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new UndeclaredThrowableException(e);
}
... and then use it everywhere as
return call(ScopedValue.where(s, value), callable);
... or even wrap the ScopedValue.Carrier class to give you exactly what you need.
--
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