Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Need better error when project.json is malformed #735

Closed
yishaigalatzer opened this issue Oct 10, 2014 · 3 comments
Closed

Need better error when project.json is malformed #735

yishaigalatzer opened this issue Oct 10, 2014 · 3 comments

Comments

@yishaigalatzer
Copy link

Repro steps

Create a folder
create a project.json file that doesn't match the json spec (say just put hello world)
kpm build

Result - Error (expected) see below, but no physical path to where it happens, so when kpm build runs inside a script you don't get enough input to where things happened.

Would like to get the full physical path to the project.json file (if available)

Error example

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while pars
ing value: E. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonTextReader.ReadInternal()
   at Newtonsoft.Json.JsonTextReader.Read()
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader)
   at Newtonsoft.Json.Linq.JObject.Parse(String json)
   at Microsoft.Framework.Runtime.Project.GetProject(String json, String project
Name, String projectPath)
   at Microsoft.Framework.Runtime.Project.TryGetProject(String path, Project& pr
oject)
   at Microsoft.Framework.PackageManager.BuildManager.Build()
   at Microsoft.Framework.PackageManager.Program.<>c__DisplayClass3.<Main>b__12(
)
   at Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Exec
ute(String[] args)
   at Microsoft.Framework.PackageManager.Program.Main(String[] args)
@am11
Copy link

am11 commented Oct 10, 2014

Microsoft uses Newtonsoft.Json in ASP.NET project systems as well as bringing the JSON support in VS (for JSON AST and indentation too I believe).

As you can see here: Microsoft.Framework.Runtime/project.json#L8, KRuntime is using 6.0.4 version (which, btw, is penultimate version and needs to be updated to 6.0.5?), while VS 2013 uses old 4.x version.

Therefore, reporting this issue to Json.NET's issue tracker (w.r.t this issue) might yield better results; as this kind of context would only be available to Newtonsoft.Json's parser.

@yishaigalatzer
Copy link
Author

The issue is not related to json.NET at all.

Its the fact that kruntime doesn't provide the path to the file it opened. The code calls json.Net with a string.

@glennc glennc added this to the 1.0.0-rc1 milestone Oct 15, 2014
@davidfowl davidfowl modified the milestones: 1.0.0-rc1, 1.0.0-beta2 Nov 3, 2014
@davidfowl davidfowl modified the milestones: 1.0.0-beta2, 1.0.0-rc1 Dec 7, 2014
@muratg muratg modified the milestones: 1.0.0-beta5, 1.0.0-beta4 Mar 19, 2015
@muratg muratg modified the milestones: 1.0.0-beta6, 1.0.0-beta5 May 12, 2015
@BrennanConroy
Copy link
Member

This should be fixed with 6b0dc2b

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

No branches or pull requests

7 participants