anchor.diff:    }
   
     void sendServerErrorNotification(String message, exception, stackTrace) {
  -    final fullError = new StringBuffer();
  -
  -    fullError.writeln(exception == null ? message : '$message: $exception');
  +    message = exception == null ? message : '$message: $exception';
   
       // Show message (without stack) to the user.
  -    showError(fullError.toString());
  -
  -    if (stackTrace != null) {
  -      fullError.writeln(stackTrace.toString());
  -    }
  +    showError(message);
  +
  +    logException(message, exception, stackTrace);
  +  }
  +
  +  /// Logs an exception by sending it to the client (window/logMessage) and
  +  /// recording it in a buffer on the server for diagnostics.
  +  void logException(String message, exception, stackTrace) {
  +    if (exception is CaughtException) {
  +      stackTrace ??= exception.stackTrace;
  +    }
  +
  +    final fullError = stackTrace == null ? message : '$message\n$stackTrace';
  +
       // Log the full message since showMessage above may be truncated or formatted
       // badly (eg. VS Code takes the newlines out).
  -    logError(fullError.toString());
  +    logErrorToClient(fullError);
   
       // remember the last few exceptions
  -    if (exception is CaughtException) {
  -      stackTrace ??= exception.stackTrace;
  -    }
       exceptions.add(new ServerException(
         message,
         exception,
  
positive.code:                 errorMessage,
                  null,
                ));
            logError(error.toString());
            if (stackTrace != null) {
              logError(stackTrace.toString());
            }
          }
        });
      }, onError: error);
    }
  
    void logError(String message) {
      channel.sendNotification(new NotificationMessage(
        Method.window_logMessage,
        new LogMessageParams(MessageType.Error, message),
  
negative.code:       messageHandler = new FailureStateMessageHandler(this);
  
        final message = 'An unrecoverable error occurred.';
        logErrorToClient(
            '$message\n\n${error.message}\n\n${error.code}\n\n${error.data}');
  
        shutdown();
  