-
Notifications
You must be signed in to change notification settings - Fork 14
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
Context required for error messages when using nested Configurations #31
Comments
Version 3.0.0 (currently in beta on pub; 3.0.0-2) provides the behavior you are looking for - can you give that a shot to see if it solves the issue? |
Good This is good. The new version 3.0.0-b2 includes a list of key paths, which is a big improvement. For the above example, the toString on the ConfigurationException produces:
And if the top-level "host" was missing, it produces this:
So the information is in there. But now the error message is a bit long, going over two lines. Better It would be better if the message produced by toString was written for the end-user to read, rather than for the developer. Since "AppConfig" is only meaningful to someone who has access to the source code. Something like:
Best I don't know how much effort is involved, but it would even be better if ConfigurationException had a separate member for the key name(s), instead of embedding it into its message member as a single string that said 'missing required key(s): "host"'. And what was thrown was a subclass of ConfigurationException (e.g. a new MissingKey), whose toString method would combine the key path (if any) and key name(s) to produce the string. Note: I wouldn't call it MissingKeyConfigurationException, since the dartdoc generated documentation uses fixed width columns and that long class name probably won't fit. That way, the program can generate its own error message if it wanted to. P.S. Just noticed ConfigurationError and ConfigurationException do not |
When an error occurs in a nested Configuration, there is no context of where it came from.
For example, consider the following program:
And the following invalid configuration file (it is missing the "host" for the "slave"):
It prints out:
But there is no indication of where exactly it was missing from. Is it the top level one, the one nested inside "master" or nested inside "slave"?
This makes finding and fixing errors in large/complex configuration files very difficult. Especially for users of the application, who don't have access to the source code and might not read any documentation about the expected configuration format.
It would be better if the exception said something like "Missing required value: slave:host". It would even be better if it could indicate the line number where the error occurred.
The text was updated successfully, but these errors were encountered: