Some exception cleanup
- Use HyracksDataException and IOException for errors ingesting external
data (instead of a mixture of AlgebricksException, AsterixException, and
HyracksDataException).
- Avoid unnecessary wrapping of exceptions.
- Wrap exception at boundaries (e.g. HiveRecordParser)
- ADMLexerException and ADMDataParser.ParseException extend
HyracksDataException
- Tighter exception declarations and handling for internal methods.
Change-Id: Icf9591046c44f5fa2281874ff0c98d780e741267
Reviewed-on: https://asterix-gerrit.ics.uci.edu/603
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <hubailmor@gmail.com>
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/org/apache/asterix/lexergenerator/LexerGenerator.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/org/apache/asterix/lexergenerator/LexerGenerator.java
index 1588c39..3ae7339 100644
--- a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/org/apache/asterix/lexergenerator/LexerGenerator.java
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/org/apache/asterix/lexergenerator/LexerGenerator.java
@@ -131,14 +131,14 @@
Set<String> functions = main.neededAuxFunctions();
for (String token : functions) {
result.append("private int parse_" + token
- + "(char currentChar) throws IOException, [LEXER_NAME]Exception{\n");
+ + "(char currentChar) throws IOException {\n");
result.append(tokens.get(token).getNode().toJavaAuxFunction());
result.append("\n}\n\n");
}
return result.toString();
}
- private static String readFile(Reader input) throws FileNotFoundException, IOException {
+ private static String readFile(Reader input) throws IOException {
StringBuffer fileData = new StringBuffer(1000);
BufferedReader reader = new BufferedReader(input);
char[] buf = new char[1024];
@@ -152,14 +152,14 @@
return fileData.toString();
}
- private static String readFile(InputStream input) throws FileNotFoundException, IOException {
+ private static String readFile(InputStream input) throws IOException {
if (input == null) {
throw new FileNotFoundException();
}
return readFile(new InputStreamReader(input));
}
- private static String readFile(String fileName) throws FileNotFoundException, IOException {
+ private static String readFile(String fileName) throws IOException {
return readFile(new FileReader(fileName));
}
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java
index 9030eb2..2701319 100644
--- a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/LexerException.java
@@ -18,7 +18,7 @@
*/
package [PACKAGE];
-public class [LEXER_NAME]Exception extends Exception {
+public class [LEXER_NAME]Exception extends [EXCEPTION_SUPER_CLASS] {
public [LEXER_NAME]Exception(String message) {
super(message);
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/default.config b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/default.config
index 63e0dd3..03a98dd 100644
--- a/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/default.config
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/resources/default.config
@@ -20,9 +20,10 @@
# Place *first* the generic configuration
# then list your grammar.
-PACKAGE: com.my.lexer
-LEXER_NAME: MyLexer
-OUTPUT_DIR: output
+PACKAGE: com.my.lexer
+LEXER_NAME: MyLexer
+EXCEPTION_SUPER_CLASS: java.io.IOException
+OUTPUT_DIR: output
TOKENS: