Skip to content

Commit 235fdef

Browse files
committed
feat(devex): Improve "Open in Editor" diagnostics
This commit enhances the "Open in Editor" feature by providing more informative error messages and adding detailed diagnostic logging. These changes will help users troubleshoot path mapping issues more effectively. Key changes: - Updated the error message in `onSocketOpeninEditor` to suggest configuring the `pathMapping` in `launch.json`. - Improved the error message in `parseUrlToUri` to provide a clearer explanation of the issue and suggest a solution. - Added `console.log` statements to `parseUrlToUri` to trace the URL transformation process and aid in debugging.
1 parent aae6581 commit 235fdef

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/devtoolsPanel.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export class DevToolsPanel {
399399
await ErrorReporter.showErrorDialog({
400400
errorCode: ErrorCodes.Error,
401401
title: 'Error while opening file in editor.',
402-
message: `Could not open document. No workspace mapping was found for '${url}'.`,
402+
message: `Could not open document. No workspace mapping was found for '${url}'. Please configure the 'pathMapping' in your 'launch.json' file.`,
403403
});
404404
}
405405
}
@@ -491,6 +491,7 @@ export class DevToolsPanel {
491491
}
492492

493493
private async parseUrlToUri(url: string): Promise<vscode.Uri | undefined> {
494+
console.log(`Original URL: ${url}`);
494495
// Convert the devtools url into a local one
495496
let sourcePath = url;
496497
let appendedEntryPoint = false;
@@ -512,6 +513,7 @@ export class DevToolsPanel {
512513
if (this.config.sourceMaps) {
513514
sourcePath = applyPathMapping(sourcePath, this.config.sourceMapPathOverrides);
514515
}
516+
console.log(`Source path after entrypoint and source map path overrides: ${sourcePath}`);
515517

516518
// Convert the local url to a workspace path
517519
const transformer = new debugCore.UrlPathTransformer();
@@ -521,6 +523,7 @@ export class DevToolsPanel {
521523
// marking it explicitly as invalid to clarify intention.
522524
const localSource = { path: sourcePath, origin: 'invalid-origin://' };
523525
await transformer.fixSource(localSource);
526+
console.log(`Local source path after transformation: ${localSource.path}`);
524527

525528
// per documentation if the file was correctly resolved origin will be cleared.
526529
// https://github.com/Microsoft/vscode-chrome-debug-core/blob/main/src/transformers/urlPathTransformer.ts
@@ -535,7 +538,7 @@ export class DevToolsPanel {
535538
await ErrorReporter.showInformationDialog({
536539
errorCode: ErrorCodes.Error,
537540
title: 'Unable to open file in editor.',
538-
message: `${sourcePath} does not map to a local file.${appendedEntryPoint ? entryPointErrorMessage : ''}`,
541+
message: `Could not open '${sourcePath}' in the editor. Make sure that the file is part of the workspace and that 'pathMapping' is configured correctly in your 'launch.json'.${appendedEntryPoint ? entryPointErrorMessage : ''}`,
539542
});
540543
}
541544

0 commit comments

Comments
 (0)