-
Notifications
You must be signed in to change notification settings - Fork 0
#4 implement a error code message builder #5
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
base: main
Are you sure you want to change the base?
Conversation
Prepend elements instead of appending them.
| const std::string_view & _error_message, | ||
| const std::string_view & _error_mitigations, | ||
| size_t _nr_parameters, | ||
| const char* const* _parameters); |
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 syntax for the pointer to pointer is a bit weird
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.
You are right, there was a missing const, added.
|
|
||
| ## Error code collection | ||
|
|
||
| If you want to enable the error code collection (for example in a separate executable), you also need to declare the preprocessor constant `ERROR_MESSAGE_COLLECTION` **before** including the main header file `error_message.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.
Add that you can also set it globally via compiler flags
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.
and we probably should have an example project, where we show, how to use these flags.
| * | ||
| * @return A string containing all registered error-codes in the following format: | ||
| * @code{.json} | ||
| * [{ "code": "EC_1" , "message": "Error Message 1", |
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.
- First question, is this the format the crawler expects.
- Second, for the error code, we need to replace underscore with dash.
| * @endcode | ||
| * | ||
| */ | ||
| #define MITIGATIONS(...) MACRO_CHOOSER(MITIGATIONS, __VA_ARGS__)(__VA_ARGS__) |
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 need an example which shows how this get replaced step by step.
| * The class will automatically register itself to the global linked list in the constructor. | ||
| * @endinternal | ||
| */ | ||
| #define DECLARE_ERROR_BUILDER_CLASS_NO_PARAM(EC, EM, MITIG) \ |
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 there any reason that the parameter names of the macro are shortened
| namespace error_reporting { \ | ||
| DECLARE_ERROR_BUILDER_CLASS_NO_PARAM(EC, EM, MITIG) \ | ||
| } \ | ||
| ERROR_MESSAGE_CLASS_INSTANCE_MODIFIER error_reporting::EC##_class EC; \ |
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.
Should we maybe add the variables itself also to the namespace, such that we don't pollute the default namespace to much.
| #define DECLARE_ERROR_BUILDER_CLASS_NO_PARAM(EC, EM, MITIG) \ | ||
| class EC##_class : public error_message_declaration_internal { \ | ||
| public: \ | ||
| static constexpr std::string_view error_code_str = #EC; \ |
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.
Do we check somewhere the structure of the error code?
| * Helper macro to retrieve all descriptions as a comma separated list from arguments. | ||
| * @endinternal | ||
| */ | ||
| #define PARAM_DESCR_FUNCTION(...) EXPAND(GET_MACRO(__VA_ARGS__, PARAM_DESCR_FUNCTION5, PARAM_DESCR_FUNCTION5, \ |
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 need an example where this gets replaced step by step.
| * EC.build().setP1(1).setP2(2).str() | ||
| * @endcode | ||
| */ | ||
| #define DECLARE_ERR_MSG_PARAMS(EC, EM, MITIG, ...) \ |
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.
I think, we need an example, how this looks after all Macros are replaced.
| } | ||
|
|
||
| inline std::string error_message_declaration_internal::str() { | ||
| std::string msg = std::string(error_code) + ": " + std::string(error_message); |
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 need to replace underscore with dashes in the error code.
No description provided.