Skip to content

Commit bce82f9

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 bce82f9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/devtoolsPanel.ts

Lines changed: 13 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,9 @@ export class DevToolsPanel {
491491
}
492492

493493
private async parseUrlToUri(url: string): Promise<vscode.Uri | undefined> {
494+
if (vscode.debug.activeDebugSession) {
495+
console.log(`Original URL: ${url}`);
496+
}
494497
// Convert the devtools url into a local one
495498
let sourcePath = url;
496499
let appendedEntryPoint = false;
@@ -513,6 +516,10 @@ export class DevToolsPanel {
513516
sourcePath = applyPathMapping(sourcePath, this.config.sourceMapPathOverrides);
514517
}
515518

519+
if (vscode.debug.activeDebugSession) {
520+
console.log(`Source path after entrypoint and source map path overrides: ${sourcePath}`);
521+
}
522+
516523
// Convert the local url to a workspace path
517524
const transformer = new debugCore.UrlPathTransformer();
518525
void transformer.launch({ pathMapping: this.config.pathMapping });
@@ -522,6 +529,10 @@ export class DevToolsPanel {
522529
const localSource = { path: sourcePath, origin: 'invalid-origin://' };
523530
await transformer.fixSource(localSource);
524531

532+
if (vscode.debug.activeDebugSession) {
533+
console.log(`Local source path after transformation: ${localSource.path}`);
534+
}
535+
525536
// per documentation if the file was correctly resolved origin will be cleared.
526537
// https://github.com/Microsoft/vscode-chrome-debug-core/blob/main/src/transformers/urlPathTransformer.ts
527538
if (!localSource.origin) {
@@ -535,7 +546,7 @@ export class DevToolsPanel {
535546
await ErrorReporter.showInformationDialog({
536547
errorCode: ErrorCodes.Error,
537548
title: 'Unable to open file in editor.',
538-
message: `${sourcePath} does not map to a local file.${appendedEntryPoint ? entryPointErrorMessage : ''}`,
549+
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 : ''}`,
539550
});
540551
}
541552

0 commit comments

Comments
 (0)