Skip to content

Conversation

@leslierichardson95
Copy link
Owner

This pull request improves cancellation support and error handling across several command implementations in the docfx tool. The main changes ensure that long-running operations can be cancelled gracefully using a CancellationToken, and that the application returns appropriate exit codes and logs warnings when operations are cancelled.

Enhanced cancellation support and error handling:

  • Updated command execution methods (BuildCommand, DefaultCommand, MergeCommand, PdfCommand, and DownloadCommand) to accept and properly handle CancellationToken, ensuring operations can be cancelled cleanly and return the correct exit code (130) when cancelled. [1] [2] [3] [4] [5]
  • Modified CommandHelper.Run and CommandHelper.RunAsync to catch OperationCanceledException, log a warning, and return exit code 130 if cancelled, instead of -1 or 0.

Refactoring and consistency improvements:

  • Refactored DownloadCommand to be asynchronous, use proper logging, and support cancellation, improving consistency with other commands.
  • Added checks for cancellation before performing subsequent operations (e.g., serving, PDF creation) to avoid unnecessary work after cancellation is requested. [1] [2]

These changes make the command-line experience more robust, especially when running long builds or downloads that may need to be interrupted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants