tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ok...@apache.org
Subject [18/50] incubator-tinkerpop git commit: TINKERPOP3-945 - added root cause to exceptions where a root cause is available
Date Thu, 03 Dec 2015 16:43:14 GMT
TINKERPOP3-945 - added root cause to exceptions where a root cause is available


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/05f4f2b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/05f4f2b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/05f4f2b6

Branch: refs/heads/TINKERPOP3-982
Commit: 05f4f2b625c11c1276f5b5796846e99871bd90b3
Parents: df887ac
Author: Marvin Froeder <velo.br@gmail.com>
Authored: Tue Nov 10 08:22:12 2015 +1300
Committer: Marvin Froeder <velo.br@gmail.com>
Committed: Sun Nov 29 00:04:41 2015 +1300

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/structure/Graph.java | 18 ++++++++++++++++--
 .../tinkerpop/gremlin/structure/Property.java     |  6 +++++-
 .../gremlin/neo4j/structure/Neo4jEdge.java        |  2 +-
 .../neo4j/structure/Neo4jGraphVariables.java      |  2 +-
 .../structure/trait/MultiMetaNeo4jTrait.java      |  2 +-
 .../structure/trait/NoMultiNoMetaNeo4jTrait.java  |  2 +-
 6 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/05f4f2b6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
index fc64400..1684cac 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
@@ -364,9 +364,13 @@ public interface Graph extends AutoCloseable, Host {
             public static IllegalArgumentException variableValueCanNotBeNull() {
                 return new IllegalArgumentException("Graph variable value can not be null");
             }
-
+            
             public static UnsupportedOperationException dataTypeOfVariableValueNotSupported(final
Object val) {
-                return new UnsupportedOperationException(String.format("Graph variable value
[%s] is of type %s is not supported", val, val.getClass()));
+            	return dataTypeOfVariableValueNotSupported(val, null);
+            }
+
+            public static UnsupportedOperationException dataTypeOfVariableValueNotSupported(final
Object val, final Exception rootCause) {
+                return new UnsupportedOperationException(String.format("Graph variable value
[%s] is of type %s is not supported", val, val.getClass()), rootCause);
             }
         }
 
@@ -1129,6 +1133,16 @@ public interface Graph extends AutoCloseable, Host {
                     new NoSuchElementException("The " + elementClass.getSimpleName().toLowerCase()
+ " with id null does not exist in the graph") :
                     new NoSuchElementException("The " + elementClass.getSimpleName().toLowerCase()
+ " with id " + id + " of type " + id.getClass().getSimpleName() + " does not exist in the
graph");
         }
+        
+        public static NoSuchElementException elementNotFound(final Class<? extends Element>
elementClass, final Object id, final Exception rootCause) {
+        	NoSuchElementException elementNotFoundException;
+        	if(null == id)
+        		elementNotFoundException = new NoSuchElementException("The " + elementClass.getSimpleName().toLowerCase()
+ " with id null does not exist in the graph");
+    		else
+    			elementNotFoundException = new NoSuchElementException("The " + elementClass.getSimpleName().toLowerCase()
+ " with id " + id + " of type " + id.getClass().getSimpleName() + " does not exist in the
graph");
+        	elementNotFoundException.initCause(rootCause);
+			return elementNotFoundException;
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/05f4f2b6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Property.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Property.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Property.java
index 33599f9..f308bf5 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Property.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Property.java
@@ -156,7 +156,11 @@ public interface Property<V> {
         }
 
         public static IllegalArgumentException dataTypeOfPropertyValueNotSupported(final
Object val) {
-            return new IllegalArgumentException(String.format("Property value [%s] is of
type %s is not supported", val, val.getClass()));
+        	return dataTypeOfPropertyValueNotSupported(val, null);
+        }
+
+        public static IllegalArgumentException dataTypeOfPropertyValueNotSupported(final
Object val, final Exception rootCause) {
+            return new IllegalArgumentException(String.format("Property value [%s] is of
type %s is not supported", val, val.getClass()), rootCause);
         }
 
         public static IllegalStateException propertyRemovalNotSupported() {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/05f4f2b6/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jEdge.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jEdge.java
b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jEdge.java
index 0ef5fcb..29ccef1 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jEdge.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jEdge.java
@@ -120,7 +120,7 @@ public final class Neo4jEdge extends Neo4jElement implements Edge, WrappedEdge<N
             this.baseElement.setProperty(key, value);
             return new Neo4jProperty<>(this, key, value);
         } catch (final IllegalArgumentException e) {
-            throw Property.Exceptions.dataTypeOfPropertyValueNotSupported(value);
+            throw Property.Exceptions.dataTypeOfPropertyValueNotSupported(value, e);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/05f4f2b6/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraphVariables.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraphVariables.java
b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraphVariables.java
index 9eef1ed..50d8cea 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraphVariables.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraphVariables.java
@@ -66,7 +66,7 @@ public final class Neo4jGraphVariables implements Graph.Variables {
         try {
             this.baseGraph.setProperty(key, value);
         } catch (final IllegalArgumentException e) {
-            throw Graph.Variables.Exceptions.dataTypeOfVariableValueNotSupported(value);
+            throw Graph.Variables.Exceptions.dataTypeOfVariableValueNotSupported(value, e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/05f4f2b6/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/MultiMetaNeo4jTrait.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/MultiMetaNeo4jTrait.java
b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/MultiMetaNeo4jTrait.java
index a4ad12b..858ace0 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/MultiMetaNeo4jTrait.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/MultiMetaNeo4jTrait.java
@@ -173,7 +173,7 @@ public final class MultiMetaNeo4jTrait implements Neo4jTrait {
                 return property;
             }
         } catch (final IllegalArgumentException iae) {
-            throw Property.Exceptions.dataTypeOfPropertyValueNotSupported(value);
+            throw Property.Exceptions.dataTypeOfPropertyValueNotSupported(value, iae);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/05f4f2b6/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/NoMultiNoMetaNeo4jTrait.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/NoMultiNoMetaNeo4jTrait.java
b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/NoMultiNoMetaNeo4jTrait.java
index 1946493..6698887 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/NoMultiNoMetaNeo4jTrait.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/trait/NoMultiNoMetaNeo4jTrait.java
@@ -105,7 +105,7 @@ public final class NoMultiNoMetaNeo4jTrait implements Neo4jTrait {
             vertex.getBaseVertex().setProperty(key, value);
             return new Neo4jVertexProperty<>(vertex, key, value);
         } catch (final IllegalArgumentException iae) {
-            throw Property.Exceptions.dataTypeOfPropertyValueNotSupported(value);
+            throw Property.Exceptions.dataTypeOfPropertyValueNotSupported(value, iae);
         }
     }
 


Mime
View raw message