Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils: Treat VSCode's CancellationError as a user-cancelled error #1583

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

bwateratmsft
Copy link
Contributor

No description provided.

@bwateratmsft bwateratmsft requested a review from a team as a code owner September 14, 2023 15:11
@@ -90,7 +90,8 @@ export function parseError(error: any): IParsedError {
isUserCancelledError:
// check using both methods in case error was created before we implemented isUserCancelledError
isUserCancelledError(error) ||
errorType === 'UserCancelledError'
errorType === 'UserCancelledError' ||
error instanceof vscode.CancellationError
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we usually like to avoid instanceof but in this case it seems to be the only option. The errorType comes out as P (yup, just P) due to VSCode's name minification. instanceof does work, however. It seems to still work even when different versions of @types/vscode are in play. I'm guessing because it's the same engine no matter what.

Copy link
Member

@alexweininger alexweininger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Curious, is this change to fix behavior or for telemetry or something else?

@bwateratmsft
Copy link
Contributor Author

Looks good. Curious, is this change to fix behavior or for telemetry or something else?

@alexweininger we're doing a registry extensibility package that uses @types/vscode but not @microsoft/vscode-azext-utils. It throws vscode.CancellationError since it doesn't have access to UserCancelledError. But the error was being caught in a callWithTelemetryAndErrorHandling block, and we wanted to have it treated the same as UserCancelledError.

@bwateratmsft bwateratmsft merged commit d3a81b5 into main Sep 14, 2023
4 checks passed
@bwateratmsft bwateratmsft deleted the bmw/cancellationerror branch September 14, 2023 16:57
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