tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [16/17] tinkerpop git commit: Fixed and simplified 'language not supported' formatting
Date Mon, 23 Jan 2017 12:45:56 GMT
Fixed and simplified 'language not supported' formatting


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

Branch: refs/heads/TINKERPOP-1560
Commit: f84f454ec456ec0d3ad39fc01c0d71b1fa217d4b
Parents: 62785dc
Author: Joshua Shinavier <josh@fortytwo.net>
Authored: Fri Jan 20 22:24:29 2017 -0800
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Mon Jan 23 07:32:23 2017 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/groovy/engine/ScriptEngines.java  | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f84f454e/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java
b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java
index 6911419..7dcfc5c 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java
@@ -110,8 +110,7 @@ public class ScriptEngines implements AutoCloseable {
      * Evaluate a script with {@code Bindings} for a particular language.
      */
     public Object eval(final String script, final Bindings bindings, final String language)
throws ScriptException {
-        if (!scriptEngines.containsKey(language))
-            throw new IllegalArgumentException(String.format("Language [%s] not supported",
language));
+        checkLanguageIsSupported(language);
 
         awaitControlOp();
 
@@ -126,8 +125,7 @@ public class ScriptEngines implements AutoCloseable {
      */
     public Object eval(final Reader reader, final Bindings bindings, final String language)
             throws ScriptException {
-        if (!scriptEngines.containsKey(language))
-            throw new IllegalArgumentException("Language [%s] not supported");
+        checkLanguageIsSupported(language);
 
         awaitControlOp();
 
@@ -454,4 +452,10 @@ public class ScriptEngines implements AutoCloseable {
         all.putAll(bindings);
         return all;
     }
+
+    private void checkLanguageIsSupported(final String language) {
+        if (!scriptEngines.containsKey(language)) {
+            throw new IllegalArgumentException(String.format("Language [%s] not supported",
language));
+        }
+    }
 }


Mime
View raw message