GitHub user spmallette opened a pull request:
https://github.com/apache/incubator-tinkerpop/pull/188
TINKERPOP-1055 Gremlin Console FileNotFoundException can be misleading
https://issues.apache.org/jira/browse/TINKERPOP-1055
Some relatively minor refactoring required to get this working. Tested
manually only as I wasn't sure how to write tests around the console when it
was calling `System.exit(1)` on error. I first tested a "good" script:
```text
$ cat test.groovy
x=1
addItUp = {x,y -> x+y}
$ bin/gremlin.sh test.groovy
\,,,/
(o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
==>1
==>groovysh_evaluate$_run_closure1@5536379e
gremlin> addItUp(1,10)
==>11
```
Then I tested a script that wasn't present on the file system:
```text
$ bin/gremlin.sh test1.groovy
\,,,/
(o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
Gremlin initialization file not found at [test1.groovy].
```
Finally, I tested a script with an error in the script itself:
```text
$ cat test-fail.groovy
x = 1
y = x / 0
$ bin/gremlin.sh test-fail.groovy
\,,,/
(o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
==>1
Bad line in Gremlin initialization file at [y = x / 0] - Division by zero
```
VOTE: +1
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/apache/incubator-tinkerpop TINKERPOP-1055
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-tinkerpop/pull/188.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #188
----
commit 1f6cb945c5ed0171a502c6468a648e8063fa1bef
Author: Stephen Mallette <[email protected]>
Date: 2015-12-29T18:41:22Z
Better error reporting around gremlin.sh init script.
Refactored code a bit to catch exceptions related to IO on the init script
itself versus errors in line of code evaluation. Not sure how to write tests
here since we call System.exit(1) on error.
commit 5463bd9cff76624067994e2469047d5ebbb305b6
Author: Stephen Mallette <[email protected]>
Date: 2015-12-29T18:44:11Z
Update changelog.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---