From 331d29f73e90a45b04b8f7f9845b9e6bd15cd4c2 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Wed, 7 Mar 2018 12:34:42 +0200 Subject: [PATCH] Improved exceptions & logging & debugging of GraphModuleSourceRepository refs #7804 Change-Id: Ia3fcd7f9e42e704d544382cd8257b035526addb6 --- .../scl/GraphModuleSourceRepository.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/GraphModuleSourceRepository.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/GraphModuleSourceRepository.java index 3d767f520..f3f5b9170 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/GraphModuleSourceRepository.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/scl/GraphModuleSourceRepository.java @@ -51,7 +51,7 @@ public enum GraphModuleSourceRepository implements ModuleSourceRepository { else return Simantics.getAvailableRequestProcessor().syncRequest(request); } catch (DatabaseException e) { - LOGGER.error("Failed to read graph module " + moduleName + ".", e); + LOGGER.error("Failed to read graph module {}.", moduleName, e); return null; } } @@ -96,10 +96,15 @@ public enum GraphModuleSourceRepository implements ModuleSourceRepository { @Override public void exception(ReadGraph graph, Throwable t) throws DatabaseException { - t.printStackTrace(); + LOGGER.error("Could not listen {}", this, t); if(alreadyExecutedOnce && listener != null) fireUpdate(graph); } + + @Override + public String toString() { + return moduleName + " " + listener + " (" + alreadyExecutedOnce + ") [" + getClass().toString() + "]"; + } }; public static class GraphModuleSource extends StringModuleSource { @@ -121,7 +126,7 @@ public enum GraphModuleSourceRepository implements ModuleSourceRepository { try { Simantics.getSession().syncRequest(new WriteModuleSource(getModuleName(), newSourceText)); } catch (DatabaseException e) { - e.printStackTrace(); + LOGGER.error("Could not update {} with newSourceText {}", this, newSourceText); } } @@ -197,8 +202,9 @@ public enum GraphModuleSourceRepository implements ModuleSourceRepository { @Override public void forAllModules(TObjectProcedure procedure) { + THashSet moduleURIs = null; try { - THashSet moduleURIs = Simantics.getAvailableRequestProcessor().syncRequest(new Read>() { + moduleURIs = Simantics.getAvailableRequestProcessor().syncRequest(new Read>() { @Override public THashSet perform(ReadGraph graph) throws DatabaseException { @@ -207,7 +213,7 @@ public enum GraphModuleSourceRepository implements ModuleSourceRepository { }); moduleURIs.forEach(procedure); } catch (DatabaseException e) { - e.printStackTrace(); + LOGGER.error("Could not execute procedure {} for all modules {}", procedure, String.valueOf(moduleURIs), e); } } -- 2.47.1