ScopedLoggingContext { @Deprecated public final void run(Runnable r) { newScope().run(r); } protected  ScopedLoggingContext(); @CheckReturnValue static ScopedLoggingContext getInstance(); @CheckReturnValue Builder newScope(); @Deprecated @MustBeClosed @CheckReturnValue abstract LoggingScope withNewScope(); @Deprecated @CheckReturnValue final Runnable wrap(final Runnable r); @Deprecated @CheckReturnValue final Callable<R> wrap(final Callable<R> c); @Deprecated final void run(Runnable r); @Deprecated final R call(Callable<R> c); abstract boolean addTags(Tags tags); abstract boolean applyLogLevelMap(LogLevelMap m);  }
@Test public void testErrorHandlingWithoutUserError() { InvalidLoggingScopeStateException e = assertThrows(InvalidLoggingScopeStateException.class, () -> ERROR_CONTEXT.run(() -> {})); assertThat(e).hasCauseThat().isInstanceOf(IllegalArgumentException.class); assertThat(e).hasCauseThat().hasMessageThat().isEqualTo("BAD CONTEXT"); }
@Test public void testErrorHandlingWithUserError() { IllegalArgumentException e = assertThrows( IllegalArgumentException.class, () -> ERROR_CONTEXT.run( () -> { throw new IllegalArgumentException("User error"); })); assertThat(e).hasMessageThat().isEqualTo("User error"); }