Skip to content

Commit

Permalink
Directive exceptions catch
Browse files Browse the repository at this point in the history
  • Loading branch information
maccasoft committed May 23, 2023
1 parent b053a95 commit bd50385
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ public List<Token> getTokens() {
}

public Expression getExpression() {
if (tokens.size() == 0) {
throw new RuntimeException("expecting expression");
}

Expression node = parseLevel(parseAtom(), 0);

Token token = peek();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ public void compile(Node root) {

@Override
public void visitDirective(DirectiveNode node) {
compileDirective(node);
try {
compileDirective(node);
} catch (CompilerException e) {
logMessage(e);
} catch (Exception e) {
logMessage(new CompilerException(e, node));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ public void addTokenLiteral(Token token) {
}

public Expression getExpression() {
if (tokens.size() == 0) {
throw new RuntimeException("expecting expression");
}

Expression node = parseLevel(parseAtom(), 0);

Token token = peek();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ public void compile(Node root) {

@Override
public void visitDirective(DirectiveNode node) {
compileDirective(node);
try {
compileDirective(node);
} catch (CompilerException e) {
logMessage(e);
} catch (Exception e) {
logMessage(new CompilerException(e, node));
}
}

@Override
Expand Down

0 comments on commit bd50385

Please sign in to comment.