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