You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by ki...@apache.org on 2022/04/13 20:42:26 UTC
[jena] branch main updated: GH-1257: Throw a CmdException in shex commands
This is an automated email from the ASF dual-hosted git repository.
kinow pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git
The following commit(s) were added to refs/heads/main by this push:
new ddcf13201c GH-1257: Throw a CmdException in shex commands
ddcf13201c is described below
commit ddcf13201c43ccd08215b228dab575ee83ab2c1b
Author: Bruno P. Kinoshita <ki...@apache.org>
AuthorDate: Tue Apr 12 11:42:20 2022 +1200
GH-1257: Throw a CmdException in shex commands
---
jena-cmds/src/main/java/shex/shex_parse.java | 13 ++++++-------
jena-cmds/src/main/java/shex/shex_validate.java | 5 ++---
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/jena-cmds/src/main/java/shex/shex_parse.java b/jena-cmds/src/main/java/shex/shex_parse.java
index 0e7b6501dc..10475c81bf 100644
--- a/jena-cmds/src/main/java/shex/shex_parse.java
+++ b/jena-cmds/src/main/java/shex/shex_parse.java
@@ -74,8 +74,7 @@ public class shex_parse extends CmdGeneral {
protected void processModulesAndArgs() {
super.processModulesAndArgs();
if ( super.positionals.size() == 0 ) {
- System.err.println(getSummary());
- System.exit(0);
+ throw new CmdException(getSummary());
}
if ( super.hasArg(argOutput) ) {
@@ -133,8 +132,7 @@ public class shex_parse extends CmdGeneral {
PrintStream err = System.err;
if ( ! FileOps.exists(fn) ) {
- err.println(fn+" : File not found");
- return;
+ throw new CmdException(fn+" : File not found");
}
try {
@@ -142,10 +140,11 @@ public class shex_parse extends CmdGeneral {
}
catch ( RiotException ex ) { /*ErrorHandler logged this */ return; }
catch (ShexParseException ex) {
+ StringBuilder sb = new StringBuilder();
if ( multipleFiles )
- err.println(fn+" : ");
- err.println(ex.getMessage());
- return;
+ sb.append(fn+" : ");
+ sb.append(ex.getMessage());
+ throw new CmdException(sb.toString());
}
boolean outputByPrev = false;
diff --git a/jena-cmds/src/main/java/shex/shex_validate.java b/jena-cmds/src/main/java/shex/shex_validate.java
index 8e64e053a4..3478413991 100644
--- a/jena-cmds/src/main/java/shex/shex_validate.java
+++ b/jena-cmds/src/main/java/shex/shex_validate.java
@@ -120,15 +120,14 @@ public class shex_validate extends CmdGeneral {
try {
shapes = Shex.readSchema(shapesfile);
} catch (ShexException ex) {
- System.err.println("Failed to read shapes: " + ex.getMessage());
- throw new CmdException();
+ throw new CmdException("Failed to read shapes: " + ex.getMessage());
}
Graph dataGraph;
try {
dataGraph = load(datafile, "data file");
} catch (RiotException ex) {
- throw new CmdException("Failed to data: " + ex.getMessage());
+ throw new CmdException("Failed to load data: " + ex.getMessage());
}
// if ( targetNode != null ) {