vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Error message for mistype environment variable is confusing

Open faxue-msft opened this issue 10 years ago • 8 comments

If user make a mistake in the environment variable in launch.json or task.json, for example mistype "${workspaceRoot}" as "${workspace}", the error message user got is confusing:

"Error Cannot read property 'hasOwnProperty' of null."

faxue-msft avatar Feb 26 '16 19:02 faxue-msft

I can not repro this with the march insider release of VSCode I tried putting ${workspace} in the program attribute in my launch.json and I get a nice warning

Can you please provide your launch.json for which you get this error message. When do you get this error message?

screen shot 2016-03-01 at 11 19 57

isidorn avatar Mar 01 '16 10:03 isidorn

@isidorn the error message does not make clear that a variable 'workspace' does not exist. Is there a better way to show this error?

weinand avatar Mar 01 '16 10:03 weinand

@weinand this error is generated by the adapter, so it can massage the error in any way. For showing a squiggle when a user uses an unexisting ${variable} is not supported right now by out json schema.

Throwing an error when we try to substitute an unexisting ${variable} might be possible, but then users will never be able to use ${} syntax in their configuration files. If you believe this is a good approach please file a feature request against Dirk.

isidorn avatar Mar 01 '16 10:03 isidorn

@isidorn the debug adapter shouldn't know anything about variables (because that's a frontend/UI concern).

From an end user perspective it would be best if we could show a squiggly in the launch.json when a variable is undefined. Could you do something similar as with the 'path not absolute' warning?

weinand avatar Mar 01 '16 10:03 weinand

With a path not absolute I use a regex https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/debug/node/debugAdapter.ts#L123

I could introduce the list of the variables we use in systemVariables to this regex but I do not think it is good to introduce this knowledge to the debug world. Thus I would be more comfortable if this lived in where all that knowledge already exists and where we replace those variables - systemVariables.ts

isidorn avatar Mar 01 '16 10:03 isidorn

@isidorn yes, I agree, this is not debug specific. It is a very useful feature for any json editor. So please file a feature request for @aeschli.

weinand avatar Mar 01 '16 10:03 weinand

ping @rick111111

isidorn avatar Mar 03 '16 16:03 isidorn

@isidorn: You are right NodeJS debugger don't have this issue.

It turned out that the debug adapter I'm working on returns an error message that directly contains ${wrongvariable} in the string, and also doesn't provide a "wrongvariable" args for string formatting.

The error message I reported is from part/debug/common/debug.ts, function formatPII() throws when it tries to format the string. I'll make a fix on my side. However it will be nice if formatPII() can directly output the string when there is no object to format in args. Or provide some option of not formatting the string.

faxue-msft avatar Mar 03 '16 21:03 faxue-msft