From: Reino Ruusu Date: Wed, 23 Oct 2019 19:03:06 +0000 (+0300) Subject: Simplify Python exception presentation X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F97%2F3397%2F1;p=simantics%2Fpython.git Simplify Python exception presentation gitlab #4 Change-Id: Ic5e80679dbcaf8276a91a95c7af8e67a8ecb483c --- diff --git a/org.simantics.pythonlink/src/org/simantics/pythonlink/PythonContext.java b/org.simantics.pythonlink/src/org/simantics/pythonlink/PythonContext.java index 62703f0..cceace3 100644 --- a/org.simantics.pythonlink/src/org/simantics/pythonlink/PythonContext.java +++ b/org.simantics.pythonlink/src/org/simantics/pythonlink/PythonContext.java @@ -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 execute(Callable 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); } }