Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when scriptInfo is missing in mapTextChangeToCodeEdit #28258

Merged
4 commits merged into from
Nov 2, 2018

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.

@@ -1966,6 +1966,11 @@ namespace ts.server {
return configProject && configProject.getCompilerOptions().configFile;
}

/* @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 Errors.ThrowNoProject();
}
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
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant