diff src/fschmidt/util/java/ComputationException.java @ 68:00520880ad02

add fschmidt source
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 05 Oct 2025 17:24:15 -0600
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fschmidt/util/java/ComputationException.java	Sun Oct 05 17:24:15 2025 -0600
@@ -0,0 +1,22 @@
+package fschmidt.util.java;
+
+import java.util.concurrent.ExecutionException;
+
+
+public final class ComputationException extends RuntimeException {
+
+	public ComputationException(Exception e) {
+		super(e);
+	}
+
+	public static ComputationException newInstance(ExecutionException e) {
+		Throwable cause = e.getCause();
+		if( cause instanceof Error )
+			throw (Error)cause;
+		if( cause instanceof RuntimeException )
+			throw (RuntimeException)cause;
+		if( cause instanceof Exception )
+			return new ComputationException((Exception)cause);
+		return new ComputationException(e);
+	}
+}