node icon indicating copy to clipboard operation
node copied to clipboard

better no value found errors

Open tanner0101 opened this issue 7 years ago • 5 comments

Feature request for Node 3.0.

It would be very nice if node errors included their keys. This will probably take some work to implement since we will need to pass the keys around to different node objects as we recurse. We can probably look into how Encodable/Decodable do it with the keyed container API.

Example of current non-helpful errors:

[Node Error: No value found at path '', expected 'String'] [Identifier: Node.NodeError.unableToConvert] [Possible Causes: typo in key path, underlying type is not convertible, unexpected '.' being interpreted as path instead of key] [Suggested Fixes: called `get(...)` on a key or key path that does not exist in the data, the data being parsed is missing required values or is incorrectly formatted, found unconvertible data, e.g., got a string of letters when an integer is required, if you have keys containing a '.' that shouldn't be interpreted as a path, use 'DotKey("actual.key")']

For code:

hosting.gitURL = try req.data.get("gitURL")

This should say something like "no value found at path gitURL". Would be even better if it suggested some possible fixes (for example there was only one other key in the dictionary, named "gitUrl", etc).

tanner0101 avatar Jul 17 '17 21:07 tanner0101

This is killer feature to me - API clients cannot fully understand errors without it. Is this already addressed in vapor 3.x trunk?

vi4m avatar Jan 31 '18 13:01 vi4m

@vi4m Node is no more in Vapor 3 since everything relies on Codable now 🎉

There probably needs to be some consideration around raising errors for missing keys etc

0xTim avatar Jan 31 '18 15:01 0xTim

Good to hear that!

vi4m avatar Jan 31 '18 17:01 vi4m

@tanner0101 Same issue. Any solutions?

vvkaghera avatar Jun 03 '19 06:06 vvkaghera

What do you mean by "same issue"? This repository has been dead for more than a year.

vzsg avatar Jun 03 '19 11:06 vzsg