Replace e.printStackTrace() with Logger in DependencyChanges 15/2515/2
authorjsimomaa <jani.simomaa@gmail.com>
Tue, 4 Dec 2018 09:22:07 +0000 (11:22 +0200)
committerJani Simomaa <jani.simomaa@semantum.fi>
Tue, 4 Dec 2018 09:22:25 +0000 (09:22 +0000)
gitlab #223

Change-Id: Ia0f585e0f78a225959e4a882760b1b3f4c73753f

bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/DependencyChanges.java

index a678abfc3a7ec3393d81b87993d6132c316c035e..87f06cc41211c50d0ff86ee9f9d9772080f74391 100644 (file)
@@ -2,6 +2,7 @@ package org.simantics.db.layer0.genericrelation;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Map;
 import java.util.TreeMap;
 
@@ -10,7 +11,6 @@ import org.simantics.databoard.annotations.Arguments;
 import org.simantics.databoard.annotations.Union;
 import org.simantics.databoard.binding.Binding;
 import org.simantics.databoard.binding.error.BindingConstructionException;
-import org.simantics.databoard.serialization.SerializationException;
 import org.simantics.databoard.serialization.Serializer;
 import org.simantics.databoard.serialization.SerializerConstructionException;
 import org.simantics.db.Metadata;
@@ -20,9 +20,13 @@ import org.simantics.db.Session;
 import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.layer0.Layer0;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DependencyChanges implements Metadata {
-    
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(DependencyChanges.class);
+
     public final @Arguments({Resource.class, Change[].class}) TreeMap<Resource, Change[]> modelChanges;
     public final boolean hasUnresolved;
     
@@ -142,18 +146,9 @@ public class DependencyChanges implements Metadata {
                Binding binding = databoard.getBinding( DependencyChanges.class );
                Serializer serializer = databoard.getSerializer( binding );
             return serializer.serialize(this);
-        } catch (SerializationException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               } catch (SerializerConstructionException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               } catch (BindingConstructionException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
+        } catch (IOException | SerializerConstructionException | BindingConstructionException e) {
+            LOGGER.error("Could not serialise {} {}", getClass().getSimpleName(), this, e);
+        }
         return new byte[0];
     }
     
@@ -163,15 +158,9 @@ public class DependencyChanges implements Metadata {
                Binding binding = databoard.getBinding( DependencyChanges.class );
                Serializer serializer = databoard.getSerializer( binding );
             return (DependencyChanges) serializer.deserialize(input); 
-        } catch (SerializationException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (SerializerConstructionException e) {
-                       e.printStackTrace();
-               } catch (BindingConstructionException e) {
-                       e.printStackTrace();
-               }
+        } catch (IOException | SerializerConstructionException | BindingConstructionException e) {
+            LOGGER.error("Could not deserialise {}", Arrays.toString(input), e);
+        }
         return null;
     }