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
highlevel: remove most of error handling from public API #2432
Conversation
1b29167
to
f42bb34
Compare
jenkins build all please |
1 similar comment
jenkins build all please |
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! If possible we should avoid having to include kdbprivate.h, otherwise everything looks very fine.
Is the high-level API ready to be released after this PR?
@@ -524,6 +524,7 @@ static ostream & printPrivate (ostream & os, parse_t & p) | |||
<< endl | |||
<< "#include <elektra/types.h>" << endl | |||
<< "#include <elektra/error.h>" << endl | |||
<< "#include <kdbprivate.h>" << 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.
Why is this needed? It would be good if we can avoid it. If it is only about the enum, we better move the enum within 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.
It's needed for ElektraErrorSeverity
, which is used in the generated function elektraErrorLowLevel
. The function is used to create the ElektraError
struct for low-level errors.
I don't think it is a problem to include kdbprivate.h
here. The generated file is elektra/errorsprivate.h
and is not intended for external use. It is not even included in any CMake install targets. It is not referenced in any header files, so it basically doesn't exist outside of compiling Elektra.
src/include/elektra/error.h
Outdated
|
||
typedef const char * ElektraKDBErrorGroup; | ||
typedef const char * ElektraKDBErrorModule; | ||
|
||
typedef void (*ElektraErrorHandler) (ElektraError * error); | ||
|
||
ElektraErrorCode elektraErrorCode (const ElektraError * 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.
Remove this also?
tests/kdb/testkdb_highlevel.cpp
Outdated
@@ -12,6 +12,7 @@ | |||
|
|||
#include <gtest/gtest-elektra.h> | |||
#include <kdbhelper.h> | |||
#include <kdbprivate.h> |
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.
We also should have ABI tests, i.e. tests that only use the public interface.
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.
The tests themselves do only access the public interface. Some use the low-level API too to check the results, but kdbprivate.h
is only used for the fatal error handler that outputs error messages. In particular we only use the elektraError
* and elektraKDBError*
functions that were part of the public interface before this PR.
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.
For ABI tests it would be needed that no methods of kdbprivate.h is used at all. Otherwise the ABI tests would also fail on changes within kdbprivate.h.
|
||
createElektra (); | ||
|
||
EXPECT_EQ (elektraGetOctet (elektra, "octet/min"), 0) << "octet/min wrong"; |
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 adding the tests!
I was thinking, now that we decided to use the |
Supporting the notification API through the highlevel API (including code generation) for example would require configuration between We should also probably provide a |
The default parameter is still needed because also kdbOpen() or some unrelated part within kdbGet() can fail. The goal would be that the application is always be able to start, independent of KDB.
You mean for elektraIoSetBinding? I don't think that "configuration" would be an elegant solution, it seems to be more straight-forward to call functions because you need to pass function pointers.
Yes, let us only add it later when it is clear that it will be needed. (e.g. if we decide not to wrap functions like elektraIoSetBinding) |
Yes, passing any sort of non-string data is very ugly via a KeySet, but I don't see a better solution other than using a custom struct which has to be allocated again. Any configuration before |
Currently |
Yes, for severe problems elektraOpen is allowed to fail. But for a later |
jenkins build all please |
1 similar comment
jenkins build all please |
Contrary to what github thinks, all build jobs where successful. One of the Cirrus CI jobs is listed twice, clicking on Details and viewing on Cirrus CI reveals that the job finished. |
Thank you for the great work! |
As discussed in #2399, this removes most of the current error access functions from the public API.
It also adds border tests for integer types and therefore closes #2430.
@markus2330 please review my pull request