Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ error-codes vs ASSERTS vs Exceptions choices choices :(
    primarykey
    data
    text
    <p><a href="https://github.com/hsyed/Rubble-DSL/blob/master/include/rbl/common/oid_container.h" rel="nofollow">Code In question</a></p> <p>I have heard (and regurgitated) the C++ exception mantra on both sides of the fence. It has been a while and I just want to centre myself once more, and this discussion is <strong>specific to the code I have linked (or low level classes such as containers)</strong>, and it's dependencies. I used to be a defensive and error_code using C programmer, but it's a tiresome practise and I am programming at a higher level of abstraction now.</p> <p>So I am rewriting a container class (and it's dependencies) to be more flexible and read better (iterators absent atm). As you can see I am returning enumerated error_codes where I know I will test them at call-site. The containers are for runtime building of AST's, initialize and make read-only. The exceptions are their to prevent the container being used naively (possibly by myself in the future). </p> <p>I have exceptions all over the place in this class, and they make me feel dirty. I appreciate their use-case. If I had the choice I might turn them off altogether (Boost uses exceptions a lot, and I am building off Boost, and yes I know they can be disabled, but when in Rome....) . I have the choice of replacing them with error_codes but hey, I will not test them , so what is the point ? </p> <p>Should I replace them with ASSERTS ? What is this bloat people speak off <a href="http://llvm.org/docs/CodingStandards.html#ci_rtti_exceptions" rel="nofollow">[1]</a> <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Exceptions" rel="nofollow">[2]</a> <a href="http://doc.qt.nokia.com/latest/exceptionsafety.html" rel="nofollow">[3]</a>? does every function callsite get extra machinery ? or only those that have a catch clause ? Since I won't catch these exceptions I shouldn't be a victim of this bloatage right ? ASSERTS do not make their way into release builds, in the context of fundamental primitive classes ( -- i.e, containers) does that even matter ? I mean how high are the chances that logic errors would find their way into a final build ? </p> <p>Since we like to answer focused questions, here is mine: <strong>What would you do, and why ?</strong> :D </p> <p><strong>Unrelated Link:</strong><a href="https://github.com/ukplc/rbl-rpc/blob/master/include/rpc/common/rpc_errors.h" rel="nofollow">Error codes and having them piggy backing in an exception.</a></p> <p><strong>edit 2</strong> in this particular case the choice is between ASSERTs and exceptions, I think exceptions make the most sense, as I mentioned above, the container is read only after initialisation, and most of the exceptions are triggered during initialisation.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload