// Path: src/com/diffplug/common/base/Errors.java
// public interface Dialog extends Consumer<Throwable> {}
// 
// Path: src/com/diffplug/common/base/Errors.java
// public interface Log extends Consumer<Throwable> {}


import org.junit.Assert;
import org.junit.Test;
import com.diffplug.common.base.Errors.Plugins.Dialog;
import com.diffplug.common.base.Errors.Plugins.Log;
		try {
			Errors.suppress().run(ErrorsTest::throwException);

			try {
				Errors.rethrow().run(ErrorsTest::throwException);
			} catch (RuntimeException e) {
				// it should pass the RuntimeException unphased
				Assert.assertNull(e.getCause());
			}
			try {
				Errors.log().run(ErrorsTest::throwException);
			} catch (RuntimeException e) {
				Assert.assertEquals("Log", e.getMessage());
			}
			try {
				Errors.dialog().run(ErrorsTest::throwException);
			} catch (RuntimeException e) {
				Assert.assertEquals("Dialog", e.getMessage());
			}
		} finally {
			DurianPlugins.resetForTesting();
			Errors.resetForTesting();
		}
	}

	private static void throwException() {
		throw new RuntimeException();
	}

	/** Implementation of the various Errors which throws a RuntimeException with the given message. */
// Path: src/com/diffplug/common/base/Errors.java
// public interface Dialog extends Consumer<Throwable> {}
// 
// Path: src/com/diffplug/common/base/Errors.java
// public interface Log extends Consumer<Throwable> {}


// Path: test/com/diffplug/common/base/ErrorsTest.java
import org.junit.Assert;
import org.junit.Test;
import com.diffplug.common.base.Errors.Plugins.Dialog;
import com.diffplug.common.base.Errors.Plugins.Log;

		try {
			Errors.suppress().run(ErrorsTest::throwException);

			try {
				Errors.rethrow().run(ErrorsTest::throwException);
			} catch (RuntimeException e) {
				// it should pass the RuntimeException unphased
				Assert.assertNull(e.getCause());
			}
			try {
				Errors.log().run(ErrorsTest::throwException);
			} catch (RuntimeException e) {
				Assert.assertEquals("Log", e.getMessage());
			}
			try {
				Errors.dialog().run(ErrorsTest::throwException);
			} catch (RuntimeException e) {
				Assert.assertEquals("Dialog", e.getMessage());
			}
		} finally {
			DurianPlugins.resetForTesting();
			Errors.resetForTesting();
		}
	}

	private static void throwException() {
		throw new RuntimeException();
	}

	/** Implementation of the various Errors which throws a RuntimeException with the given message. */
	public static class TestHandler implements Log, Dialog {