Skip to content

Commit

Permalink
ti: log caught exceptions in visit(node)
Browse files Browse the repository at this point in the history
  • Loading branch information
panchenko committed Jan 16, 2013
1 parent 4d571b2 commit dcdf89b
Showing 1 changed file with 24 additions and 1 deletion.
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.dltk.ast.ASTNode;
import org.eclipse.dltk.compiler.problem.IProblemIdentifier;
import org.eclipse.dltk.javascript.ast.ASTVisitor;
import org.eclipse.dltk.javascript.core.JavaScriptPlugin;
import org.eclipse.dltk.javascript.parser.JSProblemReporter;
import org.eclipse.dltk.javascript.parser.Reporter;
import org.eclipse.dltk.javascript.typeinference.IFunctionValueCollection;
Expand Down Expand Up @@ -113,7 +114,29 @@ public IValueReference visit(ASTNode node) {
}
}
}
return super.visit(node);
try {
return super.visit(node);
} catch (RuntimeException e) {
JavaScriptPlugin.error(buildErrorMessage(node), e);
throw e;
} catch (AssertionError e) {
JavaScriptPlugin.error(buildErrorMessage(node), e);
throw e;
}
}

private String buildErrorMessage(ASTNode node) {
final StringBuilder sb = new StringBuilder();
sb.append("Error processing ");
sb.append(node.getClass().getName());
try {
final String message = node.toString();
sb.append(" \"").append(message).append("\"");
} catch (Throwable t) {
// ignore potential errors in .toString()
}
sb.append(" in ").append(context.getSource());
return sb.toString();
}

public void done() {
Expand Down

0 comments on commit dcdf89b

Please sign in to comment.