[Feature] Provide better message when using getProp
See original GitHub issueI have a checker and using it to check some of it props
const propertyName: string = nameof<MyModel>((o) => o.headlines);
// propertyName = 'headlines'
// value is an array / should be [string, string, string?]
MyModelChecker.getProp(propertyName).strictCheck(value);
I provoked an error and the result was
Error: value[0] is not a string
at new VError (util.js?5394:20)
at DetailContext.getError (util.js?5394:91)
at Checker._doCheck (index.js?7160:179)
at Checker.strictCheck (index.js?7160:101)
at validator (MyComponent.ts?b499:24)
at assertProp (vue.esm.js?a026:1722)
at validateProp (vue.esm.js?a026:1641)
at loop (vue.esm.js?a026:4668)
at initProps (vue.esm.js?a026:4701)
at initState (vue.esm.js?a026:4642)
Could we provide the parameter value of getProp
in the message, so I could see which property is checked?
The message could be headlines[0] is not a string
or it could be MyModelChecker's headlines found: value[0] is not a string
or similar
I’m open to discussion and I’m willing to implement this feature once we’ve found a good design
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Using Window Properties - Win32 apps - Microsoft Learn
A window can create handles to its window property data and use the data for any purpose. The following example uses GetProp to...
Read more >How to define and use a system property in Android ...
I noticed that I can read system properties with System.getProperty() function. So I use setprop command to set a system property. For example:...
Read more >Adb useful commands list - gists · GitHub
Adb useful commands list. GitHub Gist: instantly share code, notes, and snippets.
Read more >OpenLayers v7.2.2 API - Class: Feature
A vector object for geographic features with a geometry and other attribute properties, similar to the features in vector file formats like GeoJSON....
Read more >dumpsys - Android Developers
This output is typically more verbose than you want, so use the command-line options on this page to get output for only the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I added
setReportedPath()
method. E.g.Should report, on error,
MyModel.headlines[0] is not a string
. I released a patch version 0.1.9.This is not unreasonable, in fact, including a diff below which might be what you are after. On the other hand, if the caller is using
getProp
, then the property is name available, so perhaps it’s OK (better?) to leave it to the caller to format errors appropriately.E.g. in your case, you could add a helper:
Diff of possible implementation changing
getProp()
to throw errors of the formpropName is not a ...
: