Fix: Display error messages when web resource upload fails due to connection timeout or expired token #284
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When using the "Upload & Publish Web Resource" feature with an expired authentication token or connection timeout, the extension would silently fail and still display a success message to the user. This created confusion as users believed their web resources were uploaded successfully when they actually failed.
In contrast, the "Compare Web Resource" feature properly displayed error messages when encountering authentication or connection issues, which was the expected behavior.
Root Cause
The issue stemmed from two problems in the error handling chain:
postData()andpatchData()methods were catching exceptions but not re-throwing them, causing errors to be silently swalloweduploadWebResourceInternal()method had no error handling and unconditionally displayed a success message regardless of whether the upload/publish operations succeededSolution
This PR implements proper error handling by:
postData()andpatchData()inrequestHelper.tsto re-throw caught exceptions after logging, ensuring errors propagate up the call stackuploadWebResourceInternal()with a try-catch block that displays a user-friendly error message when operations failErrorMessages.wrUploadErrorwith a clear message: "Failed to upload web resource. Please check your connection and try again."Impact
Files Changed
src/helpers/requestHelper.ts- Added error re-throw in catch blocks (2 methods)src/helpers/webResourceHelper.ts- Added try-catch block with error handlingsrc/utils/ErrorMessages.ts- Added new error message constantFixes #[issue_number]
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.