From c8a7033eeec2a8a4dd99a8738a7685e8d51b19fd Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Wed, 23 Oct 2019 22:03:06 +0300 Subject: [PATCH] Simplify Python exception presentation gitlab #4 Change-Id: Ic5e80679dbcaf8276a91a95c7af8e67a8ecb483c --- .../org/simantics/pythonlink/PythonContext.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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); } } -- 2.45.1