]> gerrit.simantics Code Review - simantics/python.git/blobdiff - org.simantics.pythonlink/src/org/simantics/pythonlink/PythonContext.java
Simplify Python exception presentation
[simantics/python.git] / org.simantics.pythonlink / src / org / simantics / pythonlink / PythonContext.java
index 62703f0795f0d80c6b915cf5c4022d7cfa3c71cd..cceace3c4d1b2bf9b372eeb4182d50eede2ba794 100644 (file)
@@ -318,16 +318,28 @@ public class PythonContext implements Closeable {
        static void execute(Runnable job) {
         try {
             pythonExecutor.submit(job).get();
-        } catch (InterruptedException | ExecutionException e) {
+        } catch (InterruptedException e) {
             throw new RuntimeException(e);
+        } catch (ExecutionException e) {
+            Throwable cause = e.getCause();
+            if (cause instanceof RuntimeException)
+                throw (RuntimeException) cause;
+            else
+                throw new RuntimeException(cause);
         }
     }
     
     static <V> V execute(Callable<V> job) {
         try {
             return pythonExecutor.submit(job).get();
-        } catch (InterruptedException | ExecutionException e) {
+        } catch (InterruptedException e) {
             throw new RuntimeException(e);
+        } catch (ExecutionException e) {
+            Throwable cause = e.getCause();
+            if (cause instanceof RuntimeException)
+                throw (RuntimeException) cause;
+            else
+                throw new RuntimeException(cause);
         }
     }