logException method

void logException (
  1. AstNode node,
  2. Object visitor,
  3. dynamic exception,
  4. StackTrace stackTrace
)

A function that can be used with instances of this class to log and then ignore any exceptions that are thrown by any of the delegates.

Implementation

static void logException(
    AstNode node, Object visitor, dynamic exception, StackTrace stackTrace) {
  StringBuffer buffer = StringBuffer();
  buffer.write('Exception while using a ${visitor.runtimeType} to visit a ');
  AstNode currentNode = node;
  bool first = true;
  while (currentNode != null) {
    if (first) {
      first = false;
    } else {
      buffer.write(' in ');
    }
    buffer.write(currentNode.runtimeType);
    currentNode = currentNode.parent;
  }
  // TODO(39284): should this exception be silent?
  AnalysisEngine.instance.instrumentationService.logException(
      SilentException(buffer.toString(), exception, stackTrace));
}