anchor.diff:                  errorMessage,
                   null,
                 ));
  -          logError(error.toString());
  -          if (stackTrace != null) {
  -            logError(stackTrace.toString());
  -          }
  +          logException(errorMessage, error, stackTrace);
           }
         });
       }, onError: error);
     }
   
  -  void logError(String message) {
  +  /// Logs the error on the client using window/logMessage.
  +  void logErrorToClient(String message) {
       channel.sendNotification(new NotificationMessage(
         Method.window_logMessage,
         new LogMessageParams(MessageType.Error, message),
  
positive.code:       messageHandler = new FailureStateMessageHandler(this);
  
        final message = 'An unrecoverable error occurred.';
        logError(
            '$message\n\n${error.message}\n\n${error.code}\n\n${error.data}');
  
        shutdown();
  
negative.code:   }
  
    void sendServerErrorNotification(String message, exception, stackTrace) {
      message = exception == null ? message : '$message: $exception';
  
      // Show message (without stack) to the user.
      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).
      logErrorToClient(fullError);
  
      // remember the last few exceptions
      exceptions.add(new ServerException(
        message,
        exception,
  