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

More specific error message in case of file resolution fails related to //css_import #82

Closed
maettu-this opened this issue Aug 9, 2017 · 4 comments

Comments

@maettu-this
Copy link
Collaborator

Currently, if file resolution fails, CSScriptLibrary.CSScript.Compile...() throws a System.IO.FileNotFoundException (stack trace see below) stating:

Could not find file "<Path>".
Ensure it is in one of the CS-Script search/probing directories.

Would it be possible to add more details, like stating the file where the //css_import cannot be resolved? That would help very much when implementing a highly hierarchical script code, e.g. a script library.

Stack trace:

CSScriptLibrary.FileParser.ResolveFilesDefault()
CSScriptLibrary.FileParser.ResolveFile()
CSScriptLibrary.FileParser..ctor()
CSScriptLibrary.ScriptParser.ProcessFile()
CSScriptLibrary.ScriptParser.ProcessFile()
CSScriptLibrary.ScriptParser.ProcessFile()
CSScriptLibrary.ScriptParser.ProcessFile()
CSScriptLibrary.ScriptParser.ProcessFile()
CSScriptLibrary.ScriptParser.ProcessFile()
CSScriptLibrary.ScriptParser.Init()
csscript.CSExecutor.Compile()
CSScriptLibrary.CSScript.CompileWithConfig()
CSScriptLibrary.CSScript.CompileWithConfig()
<HostingApplication>.ScriptRunner.CompileScript()
oleg-shilo added a commit that referenced this issue Aug 10, 2017
@oleg-shilo
Copy link
Owner

Yes it makes sense.
The latest commit does it:

//css_inc fake_dir\utils.cs
...

image

Soon I'll be doing release for VSCode so you'll be able to start using this feature very soon.

oleg-shilo added a commit that referenced this issue Aug 11, 2017
Further VSCode integration and defect fixes

* CLI help improvements
  - Runtime optimization
  - Fixed problem with CLI being hosted under Mono+Node.js (Console.WindowWidth is always 0)
* Throw informative exception on "in-memory" assembly being subject of "AlighnToInterface" use-case.
* Issue #82: More specific error message in case of file resolution fails related to //css_import
* Issue #81: CodeDom and interfaces
* Added CLI help content separators to assist with parsing when hosted by IDEs.
* Fixed typo in CLI output for `-proj` ('searcDir:' -> 'searchDir:')
* Started phasing out of `CSScript.Load` in favor of `CSScript.LoadFile`
Fixed typo in CLI output for -proj ('searcDir:' -> 'searchDir:')
Started phasing out of CSScript.Load in favor of CSScript.LoadFile
@maettu-this
Copy link
Collaborator Author

Upgraded to 3.27.2 and forced the exception. Three things:

Suggesting to change "Exception" on line 867 of fileparser.cs to "FileNotFoundException" to get a more specific exception type. Alternatively, retrieve the effective type of 'e' and call that constructor via reflection, or, additionally catch the more specific FileNotFoundException an then create a wrapping instance of that specific type.

Very nice that the whole calling chain is output. However, the stated "from" script is not the respective parent script but rather the top level script. That seems rather confusing. Here's a concrete example:

    Cannot import '<ScriptRootFolder>\.\Device.cs' from the '<ScriptRootFolder>\Script.cs' script.
        Cannot import '<ScriptRootFolder>\.\Library\Generic\Device.cs' from the '<ScriptRootFolder>\Script.cs' script.
            Cannot import '<ScriptRootFolder>\Library\Generic\.\IGenericDevice.cs' from the '<ScriptRootFolder>\Script.cs' script.
                Cannot import '<ScriptRootFolder>\Library\Generic\.\GenericCommand.cs' from the '<ScriptRootFolder>\Script.cs' script.
                    Cannot import '<ScriptRootFolder>\Library\Generic\.\GenericSingleLineExecuteCommand.cs' from the '<ScriptRootFolder>\Script.cs' script.
                        Cannot import '..\Framework\SingleLineExecuteCommand.cs' from the '<ScriptRootFolder>\Script.cs' script.
                            System.IO.FileNotFoundException:
                                Could not find file "<ScriptRootFolder>\Library\Generic\..\Framework\SingleLineExecuteCommand.cs".
                                Ensure it is in one of the CS-Script search/probing directories.

The last three message lines are OK, but the last forth last is confusing since Script.cs doesn't import SingleLineExecuteCommand.cs at all. It's rather GenericSingleLineExecuteCommand.cs that contains the invalid //css_import statement. I'd expect that the second stated file is the file where the error is located, not the top level script.

Finally, a minor inconsistency:
The "Cannot import" statement uses single quotes ' whereas the "Could not find file" statement uses double quotes " for the file path.

oleg-shilo added a commit that referenced this issue Aug 16, 2017
… resolution fails related to //css_import
@oleg-shilo
Copy link
Owner

All valid points.
Txs. All done. Will be available in the next release.

oleg-shilo added a commit that referenced this issue Aug 16, 2017
… resolution fails related to //css_import
oleg-shilo added a commit that referenced this issue Aug 21, 2017
* Removed '-nl' (no logo) option. Printing logo is suppressed now by default for all CLI scenarios except help, version and 'no args'.
* Added typical Linux CLI double-dash prefix for help and version.
* Added support for `scripted args` ("cscs -update" where "-update" is a script file).
* Enabled setting CS-Script runtime environment variables on Linux.
* Reviewed and refined concurrency support on Linux:
    - mutex cleanup and prompt release
    - ensuring assembly file is opened for reading during `inmem` loading
* Further improvements for issue #82.
@maettu-this
Copy link
Collaborator Author

Perfect! Users should now be able to much easier locate an issue in a larger script library like the one I've been working on the last couple of weeks. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants