function handleError()

in src/extension/src/telemetry/callWithTelemetryAndErrorHandling.ts [100:143]


function handleError(vscodeContext: ExtensionContext, context: IActionContext, callbackId: string, error: any): void {
  const errorData: IParsedError = parseError(error);
  if (errorData.isUserCancelledError) {
    context.properties.result = "Canceled";
    context.suppressErrorDisplay = true;
    context.rethrowError = false;
  } else {
    context.properties.result = "Failed";
    context.properties.error = errorData.errorType;
    context.properties.errorMessage = errorData.message;
    context.properties.stack = errorData.stack ? errorData.stack : undefined;
    if (context.suppressTelemetry) {
      context.properties.suppressTelemetry = "true";
    }
  }

  if (!context.suppressErrorDisplay) {
    let message: string;
    if (errorData.message.includes("\n")) {
      console.log(errorData.message);
      message = MESSAGES.DIALOG_MESSAGES.multiLineError;
    } else {
      message = errorData.message;
    }

    // don't wait
    window
      .showErrorMessage(message, MESSAGES.DIALOG_RESPONSES.showLog, MESSAGES.DIALOG_RESPONSES.reportAnIssue)
      .then((result: MessageItem | undefined) => {
        if (result === MESSAGES.DIALOG_RESPONSES.reportAnIssue) {
          reportAnIssue(vscodeContext, callbackId, errorData);
        } else if (result === MESSAGES.DIALOG_RESPONSES.showLog) {
          vscode.workspace
            .openTextDocument(Logger.filename)
            .then((TextDocument) => vscode.window.showTextDocument(TextDocument));
        }
      });
  }
  Logger.appendLog("EXTENSION", "error", error);
  Logger.display();
  if (context.rethrowError) {
    throw error;
  }
}