Skip to content

Improve error message when scriptInfo is missing in mapTextChangeToCodeEdit#28258

Merged
4 commits merged intomasterfrom
isNewFile
Nov 2, 2018
Merged

Improve error message when scriptInfo is missing in mapTextChangeToCodeEdit#28258
4 commits merged intomasterfrom
isNewFile

Conversation

@ghost
Copy link

@ghost ghost commented Oct 31, 2018

Should help diagnose #28233
Putting the text in a log message instead of in the exception text to avoid putting PII in exception text.


/* @internal */
allScriptInfoFileNamesForDebug(): ReadonlyArray<string> {
return arrayFrom(this.filenameToScriptInfo.keys());
Copy link
Member

Choose a reason for hiding this comment

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

I think we should have both filename and path print instead of just path to figure out if there is mismatch in casing that could cause this.

Copy link
Author

Choose a reason for hiding this comment

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

So the keys of filenameToScriptInfo are paths and not filenames? I was assuming the key to this map was the same as the value's .fileName property?

Copy link
Member

Choose a reason for hiding this comment

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

No it is path.

@ghost ghost force-pushed the isNewFile branch from 315a274 to ffdeb28 Compare November 2, 2018 00:08
return scriptInfo.getDefaultProject();
}
else {
this.logger.msg(`Cannot find ${fileName} in ${JSON.stringify(this.allScriptInfoFileNamesForDebug)}`, Msg.Err);
Copy link
Member

Choose a reason for hiding this comment

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

Needs to be this.allScriptInfoFileNamesForDebug()

/* @internal */
allScriptInfoFileNamesForDebug(): ReadonlyArray<{ readonly path: string, readonly fileName: string }> {
const out: { readonly path: string, readonly fileName: string }[] = [];
this.filenameToScriptInfo.forEach((scriptInfo, path) => {
Copy link
Member

Choose a reason for hiding this comment

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

May be use arrayFrom ?

return symLinkedProjects ? { projects: projects!, symLinkedProjects } : projects!; // TODO: GH#18217
}

private logErrorForScriptInfoNotFound(fileName: string): void {
Copy link
Member

Choose a reason for hiding this comment

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

Move this to editorServices and use it in all locations?

Copy link
Member

@sheetalkamat sheetalkamat left a comment

Choose a reason for hiding this comment

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

Need to update API as the build will fail without it but everything else is good.

@ghost ghost merged commit 92a48d8 into master Nov 2, 2018
@ghost ghost deleted the isNewFile branch November 2, 2018 23:12
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant