Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1599 64ddbaf63 -> f09baf54e (forced update)


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/3dcfa3d3
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3dcfa3d3
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3dcfa3d3

Branch: refs/heads/TINKERPOP-1599
Commit: 3dcfa3d37289c6b2d153af7d8edbe7206ecac0cb
Parents: 4443dcf
Author: Joshua Shinavier <[email protected]>
Authored: Fri Jan 20 22:24:29 2017 -0800
Committer: Joshua Shinavier <[email protected]>
Committed: Fri Jan 20 22:24:29 2017 -0800

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


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3dcfa3d3/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 1113eb5..ca3b799 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
@@ -91,8 +91,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();
 
@@ -107,8 +106,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();
 
@@ -412,4 +410,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));
+        }
+    }
 }

Reply via email to