Skip to content

Commit

Permalink
feat(solrteur): introduce custom exception to handle parsing errors I…
Browse files Browse the repository at this point in the history
…QSS#7662

Instead of relying on Java provided exceptions, we want to track line numbers
and other more details of the parsing process, so we need custom mechanics.
  • Loading branch information
poikilotherm committed Apr 26, 2022
1 parent a1b25c5 commit 39acda2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package cli.util.model;

public final class ParserError {
String message;
Integer lineNumber;

public ParserError(String message, Integer lineNumber) {
this.message = message;
this.lineNumber = lineNumber;
}

public ParserError(ParserException exception, Integer lineNumber) {
this.message = exception.getMessage();
this.lineNumber = lineNumber;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cli.util.model;

import java.util.ArrayList;
import java.util.List;

public final class ParserException extends Throwable {

final List<ParserException> subExceptions = new ArrayList<>(0);

public ParserException(String message) {
super(message);
}

public boolean hasSubExceptions() {
return subExceptions.size() > 0;
}

public void addSubException(String message) {
this.subExceptions.add(new ParserException(message));
}

public List<ParserException> getSubExceptions() {
return List.copyOf(subExceptions);
}
}

0 comments on commit 39acda2

Please sign in to comment.