Let the request processor handle the exceptions 50/1250/2
authorJussi Koskela <jussi.koskela@semantum.fi>
Wed, 22 Nov 2017 10:56:27 +0000 (12:56 +0200)
committerJussi Koskela <jussi.koskela@semantum.fi>
Wed, 22 Nov 2017 11:27:30 +0000 (13:27 +0200)
Prior to this failed write transactions were not cancelled. For
consistency the read transactions are now handled the same way.
Also deprecated legacy implementations.

refs #7633

Change-Id: Ic301acc2d7f05bb8f42df3322e94cf56b1631203

bundles/org.simantics.document.server/src/org/simantics/document/server/Functions.java

index 9c62924153681a788159cb40c0420468bc415387..0a7e004f7dcab5e75740d176100c78d59c3dfb47 100644 (file)
@@ -583,6 +583,7 @@ public class Functions {
        }
     }
 
+    @Deprecated
     public static AbstractEventHandler emptyOnClick(ReadGraph graph) throws DatabaseException {
         return new EventHandler() {
             @Override
@@ -592,6 +593,7 @@ public class Functions {
         };
     }
 
+    @Deprecated
     public static AbstractEventHandler writeEventHandler(ReadGraph graph, final Variable variable, final Function fn) {
 
        final Session session = graph.getSession();
@@ -624,15 +626,11 @@ public class Functions {
                                                        return (String)response;
                                                    }
                                                    return null;
-                                               } catch (Throwable t) {
-                                                   t.printStackTrace();
                                                } finally {
                                                        sclContext.put("graph", oldGraph);
                                                        sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter);
                                                }
 
-                                               return null;
-
                                            }
 
                                        });
@@ -649,6 +647,7 @@ public class Functions {
         };
     }
 
+    @Deprecated
     public static AbstractEventHandler readEventHandler(ReadGraph graph, final Variable variable, final Function fn) {
 
        final Session session = graph.getSession();
@@ -681,15 +680,11 @@ public class Functions {
                                                        return (String)response;
                                                    }
                                                    return null;
-                                               } catch (Throwable t) {
-                                                   t.printStackTrace();
                                                } finally {
                                                        sclContext.put("graph", oldGraph);
                                                        sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter);
                                                }
 
-                                               return null;
-
                                            }
 
                                        });
@@ -706,6 +701,7 @@ public class Functions {
         };
     }
 
+    @Deprecated
     public static AbstractEventHandler readEventHandler2(ReadGraph graph, final Function fn) {
 
        final Session session = graph.getSession();
@@ -732,15 +728,11 @@ public class Functions {
                                                        return (CommandResult)response;
                                                    }
                                                    return null;
-                                               } catch (Throwable t) {
-                                                   t.printStackTrace();
                                                } finally {
                                                        sclContext.put("graph", oldGraph);
                                                        sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter);
                                                }
 
-                                               return null;
-
                                            }
 
                                        });
@@ -830,10 +822,7 @@ public class Functions {
                                                Object oldGraph = sclContext.put("graph", graph);
                                                Object oldPrinter = sclContext.put(SCLReportingHandler.REPORTING_HANDLER, printer);
                                                try {
-                                                       Object response = fn.apply(parameters);
-                                                       return response;
-                                               } catch (Throwable t) {
-                                                       return new org.simantics.document.server.serverResponse.Error(formatError(graph, t));
+                                                       return fn.apply(parameters);
                                                } finally {
                                                        sclContext.put("graph", oldGraph);
                                                        sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter);
@@ -854,10 +843,7 @@ public class Functions {
                                                Object oldPrinter = sclContext.put(SCLReportingHandler.REPORTING_HANDLER, printer);
 
                                                try {
-                                                       Object response = fn.apply(parameters);
-                                                       return response;
-                                               } catch (Throwable t) {
-                                                       return new org.simantics.document.server.serverResponse.Error(formatError(graph, t));
+                                                       return fn.apply(parameters);
                                                } finally {
                                                        sclContext.put("graph", oldGraph);
                                                        sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter);
@@ -899,6 +885,7 @@ public class Functions {
         };
     }
 
+    @Deprecated
     public static AbstractEventHandler writeEventHandler2(ReadGraph graph, final Function fn) {
 
        final Session session = graph.getSession();
@@ -925,15 +912,11 @@ public class Functions {
                                                        return (CommandResult)response;
                                                    }
                                                    return null;
-                                               } catch (Throwable t) {
-                                                   t.printStackTrace();
                                                } finally {
                                                        sclContext.put("graph", oldGraph);
                                                        sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter);
                                                }
 
-                                               return null;
-
                                            }
 
                                        });
@@ -950,6 +933,8 @@ public class Functions {
         };
     }
 
+
+    @Deprecated
     public static AbstractEventHandler eventHandler2(ReadGraph graph, final Function fn) {
 
         return new AbstractEventHandler() {
@@ -969,14 +954,10 @@ public class Functions {
                                        return (CommandResult)response;
                                }
                                return null;
-                       } catch (Throwable t) {
-                               t.printStackTrace();
                        } finally {
                                sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter);
                        }
 
-                       return null;
-
                                } catch (Throwable e) {
                                        Logger.defaultLogError(e);
                                        return new org.simantics.document.server.serverResponse.Error(e.getMessage()); 
@@ -987,6 +968,7 @@ public class Functions {
         };
     }
 
+    @Deprecated
     public static AbstractEventHandler eventHandler(ReadGraph graph, final Function fn) {
 
         return new AbstractEventHandler() {
@@ -1013,8 +995,6 @@ public class Functions {
                                    if(response instanceof String) {
                                        result = (String)response;
                                    }
-                               } catch (Throwable t) {
-                                   t.printStackTrace();
                                } finally {
                                        sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter);
                                }