]> gerrit.simantics Code Review - simantics/python.git/commitdiff
Simplify Python exception presentation 97/3397/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Wed, 23 Oct 2019 19:03:06 +0000 (22:03 +0300)
committerReino Ruusu <reino.ruusu@semantum.fi>
Wed, 23 Oct 2019 19:03:06 +0000 (22:03 +0300)
gitlab #4

Change-Id: Ic5e80679dbcaf8276a91a95c7af8e67a8ecb483c

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);
         }
     }