Skip to content

Commit

Permalink
clean up error handling code
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewbastien committed Jan 15, 2025
1 parent 97c1bc6 commit 9e2ab90
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/documentation/DocumentationPreviewEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,23 +205,23 @@ export class DocumentationPreviewEditor implements vscode.Disposable {
},
});
} catch (error) {
if (!(error instanceof ResponseError)) {
// Update the preview editor to reflect what error occurred
let errorMessage = "An internal error occurred";
if (error instanceof ResponseError) {
if (error.code === LSPErrorCodes.RequestCancelled) {
// We can safely ignore cancellations
return undefined;
}
if (error.code === LSPErrorCodes.RequestFailed) {
errorMessage = error.message;
}
this.context.outputChannel.log(
`SourceKit-LSP request "${DocCDocumentationRequest.method}" failed:`
);
this.context.outputChannel.log(JSON.stringify(error.toJson(), undefined, 2));
} else {
this.context.outputChannel.log("failed to convert documentation:");
this.context.outputChannel.log(`${error}`);
return;
}
if (error.code === LSPErrorCodes.RequestCancelled) {
// We can safely ignore cancellations
return undefined;
}
this.context.outputChannel.log(
`SourceKit-LSP request "${DocCDocumentationRequest.method}" failed:`
);
this.context.outputChannel.log(JSON.stringify(error.toJson(), undefined, 2));
// Update the preview editor to reflect what error occurred
let errorMessage = "An internal error occurred in SourceKit-LSP";
if (error.code === LSPErrorCodes.RequestFailed) {
errorMessage = error.message;
}
this.postMessage({
type: "update-content",
Expand Down

0 comments on commit 9e2ab90

Please sign in to comment.