As far as I can tell, replacing the exception handler using CompositionLocalProvider
does not work.
More specifically, the exception handler set as the provider is never called with the thrown exception. This can be trivially witnessed by adding a breakpoint in the handler and running the debugger. The breakpoint will never trigger.
Basic unit tests included. Further unit tests might also test what happens when the exception is thrown from various different contexts.
Relevant tickets