-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Labels
Milestone
Description
Triggered by a discussion in the Alice WP3 mailing list about error handling, I propose to employ the following error handling "policy" (more in the sense of a guideline and less in the sense of a strict ruleset, simply to achieve more consistency over randomness) for FairMQ:
- State pre and postconditions via asserts / comments, violations are code bugs and need fixing, not exceptions
- Apply throughout the current FairMQ codebase and collect and document practical examples
- Decide whether to tie asserts to
NDEBUGor a separate switch (gsl's runtime asserts are not disabable at all even for release builds)
- Prefer
noexceptand strongly typed error codes via return channel - in the future: replace error codes with static exceptions- Study cases where a
noexceptinterface internally callsnoexcept(false)interfaces and decide if the "Prefernoexcept" can hold as a guideline. - Study cases where we already use C-style int error codes that do not distinguish error codes from return value by type and decide whether it is worth changing them.
- Decide for one of
<system_error>,std::experimental::expected, Boost.Outcome or similar - Practical examples
- Study cases where a
- Throw only unrecoverable (that lead to a terminate) error condition from free and member functions (should basically boil down to
std::bad_allocandstd::runtime_error("not implemented")).- Understand the consequences of a full stack unwind + automatic terminate vs early
std::terminate, especially in combination withnoexceptinterfaces, with regard to debuggability
- Understand the consequences of a full stack unwind + automatic terminate vs early
- Throw recoverable error conditions from ctors if class invariant cannot be established (to avoid 2-phase construction). Prefer to throw own exception types (possibly inheriting from a STL base exception type).
- Practical examples
The above work-in-progress guidelines try to optimize for
- debuggability/maintainability and
- runtime performance (should really mainly be achieved via rule 1 and only on second order via rule 2).
Once the above points are finished:
- Introduce new section in FairMQ docs
- Report the results back to Alice to possibly be taken into account when developing further guidelines for Alice O2 projects (@ihrivnac suggested https://github.com/AliceO2Group/CodingGuidelines/master/coding_guidelines.html#Exceptions, @ktf suggested https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/README.md#error-handling)
Cc: @davidrohr, @ihrivnac, @ktf just FYI, this will take a bit to finish, but I guess we are not in a huge hurry here and it should not really block any activities in Alice O2 projects.
References:
Reactions are currently unavailable