-
Notifications
You must be signed in to change notification settings - Fork 123
Conversation
17480a0
to
ae1ae3e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very comprehensive work, looks very good to reach all points. 🚀 Please focus on reaching a mergable state.
doc/help/kdb-validate.md
Outdated
## OPTIONS | ||
|
||
- `-d`,`--debug`: | ||
Give debug information or ask debug questions (in interactive mode). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the interactive mode? There doesn't seem to be a -i option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reporting that mistake!
That was a leftover from a copy-paste of the manpage from another tool.
Gets fixed by commit c2ec7eb.
doc/help/kdb-validate.md
Outdated
- `-d`,`--debug`: | ||
Give debug information or ask debug questions (in interactive mode). | ||
- `-f`, `--force`: | ||
Force the action to be done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force the action to be done. | |
Force writing the configuration even on warnings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good clarification!
Gets changed by commit c2ec7eb.
src/tools/kdb/validate.cpp
Outdated
throw invalid_argument ("1 argument needed"); | ||
} | ||
|
||
cout << "The given path was: " << cl.arguments[0] << endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Output only on debug (if at all). Probably more interesting is the name of the root key and not getting back exactly the given argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, I fixed it while adapting the ValidateCommand::execute()
to use the new C++ error-classes.
src/tools/kdb/validate.cpp
Outdated
|
||
if (cl.force) | ||
{ | ||
cout << getFormattedInfoString ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again: only for -v.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by commit 18edf39.
src/tools/kdb/validate.cpp
Outdated
"The validation was stopped because of warnings " | ||
"while getting the values!") | ||
<< endl; | ||
kdb.close (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is done automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, I removed the statement.
* The warning is copied to make it independent from the source object. This way the same warning added to two different errors can be | ||
* changed independently. | ||
* | ||
* An Error can contain 0 to n warnings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A key can contain 0-n warnings. I would say that the error does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we adhered to the concept that was established by the Error-Keys and also the highlevel-API (/src/libs/highlevel/elektra_error.c
).
Therefore we designed an Error-class that can hold multiple Warnings, so a Key of the C-API with 0 or 1 errors and 0 to n warnings can be directly converted to an object of type Error and the behaviour is consistent with the highlevel-API.
I extended the comment to explain the concept a bit in commit c2ec7eb.
namespace errors | ||
{ | ||
|
||
/* Not an error by itself, but a container for multiple warnings */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* Not an error by itself, but a container for multiple warnings */ | |
/* Not an warning by itself, but a container for multiple warnings */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I wrote in the previous message, an Error object can contain multiple Warnings so that an Error-key can directly be converted to a single C++ Error-object and to keep the behaviour consistent with the highlevel-API.
In commit c2ec7eb I extended the comment to explain the concept a bit more.
|
||
|
||
/* Concrete classes for the different Errors, based on the constants defined in /src/include/kdberrors.h */ | ||
class ResourceError : public Error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this could even be in src/bindings/cpp/include/kdbexcept.hpp this would need some exception mapping in src/bindings/cpp/include/kdb.hpp, though. (extra work beyond original scope of project)
src/libs/tools/src/errors/error.cpp
Outdated
{ | ||
/*TODO: Decide if ordering of warnings should be considered for equality. | ||
* Currently two errors are equal if they contain the same warnings (compared by member values), | ||
* even if they have different orders in the internal vector.*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the good feedback! 😀
Error* ErrorFactory::create(const std::string & type, const std::string & reason, const std::string & module, | ||
const std::string & file, const std::string & mountPoint, const std::string & configFile, kdb::long_t line) | ||
{ | ||
if (type == ELEKTRA_ERROR_RESOURCE || type == ELEKTRA_ERROR_RESOURCE_NAME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would be the type sometimes the _NAME and sometimes not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the bottom of /src/include/kdberrors.h
, for every introduced code four constants are defined:
#define DECLARE_ERROR_CODE(cname) \
extern const char * ELEKTRA_ERROR_##cname; \
extern const char * ELEKTRA_ERROR_##cname##_NAME; \
\
extern const char * ELEKTRA_WARNING_##cname; \
extern const char * ELEKTRA_WARNING_##cname##_NAME; \
\
void elektraSetError##cname (Key * key, const char * file, const char * line, const char * module, const char * reason, ...); \
void elektraAddWarning##cname (Key * key, const char * file, const char * line, const char * module, const char * reason, ...);
DECLARE_ERROR_CODE (RESOURCE)
DECLARE_ERROR_CODE (OUT_OF_MEMORY)
DECLARE_ERROR_CODE (INSTALLATION)
DECLARE_ERROR_CODE (INTERNAL)
DECLARE_ERROR_CODE (INTERFACE)
DECLARE_ERROR_CODE (PLUGIN_MISBEHAVIOR)
DECLARE_ERROR_CODE (CONFLICTING_STATE)
DECLARE_ERROR_CODE (VALIDATION_SYNTACTIC)
DECLARE_ERROR_CODE (VALIDATION_SEMANTIC)
#undef DECLARE_ERROR_CODE
We designed the Factories so that the ELEKTRA_ERROR_##cname
or ELEKTRA_ERROR_##cname##_NAME
are valid parameters for creating an object of the appropriate type.
Should we change that so only the Code, but not the Description/_NAME is valid here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I do not think that _NAME should be anything external. It is only needed to render the error text. I created #4230
and do some improvements and bugfixes esp. regarding handling of warnings
currently mostly a wrapper to the implementation in /src/libs/highlevel/elektra_error.c not finished or in a working state yet!
of the highlevel API
add iterator functionality for Warnings to Error class
…warnigns Warnings get now cloned when they are stored in an Error object, add further tests
add MountPoint and ConfigFile members, add a PureWarning ErrorType for a dummy Error that only encapsulats Warnings, add some testcode to /src/tools/kdb/validate.cpp
…f was set only when also -v was given
… manually - they are currently broken!)
libtools: make error and warning factories not instantiable (by deleting their default constructors and destructors)
Excellent job! 💖 |
Basics
Related issue: #3674
These points need to be fulfilled for every PR:
(added as entry in
doc/news/_preparation_next_release.md
whichcontains
_(my name)_
)Please always add something to the release notes.
(first line should have
module: short statement
syntax)close #X
, are in the commit messages.doc/news/_preparation_next_release.md
scripts/dev/reformat-all
If you have any troubles fulfilling these criteria, please write
about the trouble as comment in the PR. We will help you.
But we cannot accept PRs that do not fulfill the basics.
Checklist
Check relevant points but please do not remove entries.
For docu fixes, spell checking, and similar none of these points below
need to be checked.
(not in the PR description)
Review
Reviewers will usually check the following:
Labels
If you are already Elektra developer:
say that everything is ready to be merged.