Skip to content

Conversation

@tomuben
Copy link
Collaborator

@tomuben tomuben commented Dec 28, 2021

No description provided.

const std::string_view & _error_message,
const std::string_view & _error_mitigations,
size_t _nr_parameters,
const char* const* _parameters);
Copy link
Collaborator

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

Copy link
Collaborator Author

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`.
Copy link
Collaborator

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

Copy link
Collaborator

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",
Copy link
Collaborator

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__)
Copy link
Collaborator

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) \
Copy link
Collaborator

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; \
Copy link
Collaborator

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; \
Copy link
Collaborator

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, \
Copy link
Collaborator

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, ...) \
Copy link
Collaborator

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);
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants